Skip to content

Commit

Permalink
cmd/compile/internal/typecheck: use types.IsMethodApplicable
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Cuong Manh Le <[email protected]>
Auto-Submit: Matthew Dempsky <[email protected]>
  • Loading branch information
mdempsky authored and gopherbot committed Aug 22, 2023
1 parent 08a0808 commit 21293b6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/cmd/compile/internal/typecheck/subr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 21293b6

Please sign in to comment.