From 21293b6b87c67bc98c56b33509ae390a3352da71 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Sun, 20 Aug 2023 18:15:43 -0700 Subject: [PATCH] cmd/compile/internal/typecheck: use types.IsMethodApplicable In checking whether a type implements an interface, there's this complex predicate spanning multiple lines, which is very obtuse. So let's just use the helper function we already have in package types instead. Change-Id: I80f69d41c2bee8d6807601cf913840fa4f042b5e Reviewed-on: https://go-review.googlesource.com/c/go/+/521435 Run-TryBot: Matthew Dempsky Reviewed-by: Than McIntosh TryBot-Result: Gopher Robot Reviewed-by: Cuong Manh Le Auto-Submit: Matthew Dempsky --- src/cmd/compile/internal/typecheck/subr.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cmd/compile/internal/typecheck/subr.go b/src/cmd/compile/internal/typecheck/subr.go index d72807a778f..867eee28e72 100644 --- a/src/cmd/compile/internal/typecheck/subr.go +++ b/src/cmd/compile/internal/typecheck/subr.go @@ -763,12 +763,10 @@ func implements(t, iface *types.Type, m, samename **types.Field, ptr *int) bool *ptr = 0 return false } - followptr := tm.Embedded == 2 // if pointer receiver in method, // the method does not exist for value types. - rcvr := tm.Type.Recv().Type - if rcvr.IsPtr() && !t0.IsPtr() && !followptr && !types.IsInterfaceMethod(tm.Type) { + if !types.IsMethodApplicable(t0, tm) { if false && base.Flag.LowerR != 0 { base.Errorf("interface pointer mismatch") }