1
0
mirror of https://github.com/golang/go synced 2024-11-23 05:20:11 -07:00

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 <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Matthew Dempsky 2023-08-20 18:15:43 -07:00 committed by Gopher Robot
parent 08a08083c1
commit 21293b6b87

View File

@ -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")
}