From 850a715c79882af699d8aa58612e40a9bc8405f1 Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 20 Jul 2021 20:19:02 +0800 Subject: [PATCH] table: minor cleanup in does_type_implement_interface() (#10870) --- vlib/v/ast/table.v | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index 1234c78252..ed582f54c5 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -1109,16 +1109,15 @@ pub fn (mut t Table) bitsize_to_type(bit_size int) Type { } pub fn (mut t Table) does_type_implement_interface(typ Type, inter_typ Type) bool { - utyp := typ - if utyp.idx() == inter_typ.idx() { + if typ.idx() == inter_typ.idx() { // same type -> already casted to the interface return true } - if inter_typ.idx() == error_type_idx && utyp.idx() == none_type_idx { + if inter_typ.idx() == error_type_idx && typ.idx() == none_type_idx { // `none` "implements" the Error interface return true } - typ_sym := t.get_type_symbol(utyp) + typ_sym := t.get_type_symbol(typ) if typ_sym.language != .v { return false } @@ -1129,7 +1128,7 @@ pub fn (mut t Table) does_type_implement_interface(typ Type, inter_typ Type) boo if mut inter_sym.info is Interface { // do not check the same type more than once for tt in inter_sym.info.types { - if tt.idx() == utyp.idx() { + if tt.idx() == typ.idx() { return true } } @@ -1165,7 +1164,7 @@ pub fn (mut t Table) does_type_implement_interface(typ Type, inter_typ Type) boo } return false } - inter_sym.info.types << utyp + inter_sym.info.types << typ if !inter_sym.info.types.contains(voidptr_type) { inter_sym.info.types << voidptr_type }