@@ -533,7 +533,10 @@ fn (t &Table) method_types_are_equal(left Type, right Type) bool {
533533 return unaliased_left == unaliased_right
534534}
535535
536- fn (t &Table) method_fn_return_types_are_compatible (left Type, right Type) bool {
536+ fn (t &Table) method_return_types_are_compatible (left Type, right Type) bool {
537+ if t.method_types_are_equal (left, right) {
538+ return true
539+ }
537540 unaliased_left := t.fully_unaliased_type (left)
538541 unaliased_right := t.fully_unaliased_type (right)
539542 if unaliased_left.nr_muls () != unaliased_right.nr_muls () {
@@ -552,15 +555,22 @@ fn (t &Table) method_fn_return_types_are_compatible(left Type, right Type) bool
552555 }
553556 return t.fn_types_are_compatible (left_sym.info.func, right_sym.info.func, 0 )
554557 }
558+ if left_sym.info is MultiReturn && right_sym.info is MultiReturn {
559+ if left_sym.info.types.len != right_sym.info.types.len {
560+ return false
561+ }
562+ for i, typ in left_sym.info.types {
563+ if ! t.method_return_types_are_compatible (typ, right_sym.info.types[i]) {
564+ return false
565+ }
566+ }
567+ return true
568+ }
555569 return false
556570}
557571
558572pub fn (t &Table) is_same_method (f & Fn, func & Fn) string {
559- mut same_return_type := t.method_types_are_equal (f.return_type, func.return_type)
560- if ! same_return_type {
561- same_return_type = t.method_fn_return_types_are_compatible (f.return_type, func.return_type)
562- }
563- if ! same_return_type {
573+ if ! t.method_return_types_are_compatible (f.return_type, func.return_type) {
564574 s := t.type_to_str (f.return_type)
565575 return 'expected return type `${s }`'
566576 }
0 commit comments