go/types: remove unneccesary tests in implements and lookup

This is a port of CL 363838 from types2 to go/types.

Change-Id: I03f4da86ea38209a73f567cc5d84e7afd08883ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/364935
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Robert Findley 2021-11-17 20:04:14 -05:00
parent 9ea939be60
commit 5d5f2b1e20
2 changed files with 1 additions and 11 deletions

View File

@ -205,12 +205,6 @@ func (check *Checker) implements(V, T Type, qf Qualifier) error {
// V must implement T (methods)
// - check only if we have methods
if Ti.NumMethods() > 0 {
// If the type argument is a pointer to a type parameter, the type argument's
// method set is empty.
// TODO(gri) is this what we want? (spec question)
if base, isPtr := deref(V); isPtr && isTypeParam(base) {
return errorf("%s has no methods", V)
}
if m, wrong := check.missingMethod(V, Ti, true); m != nil {
// TODO(gri) needs to print updated name to avoid major confusion in error message!
// (print warning for now)

View File

@ -80,12 +80,8 @@ func lookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (o
typ, isPtr := deref(T)
// *typ where typ is an interface or type parameter has no methods.
// *typ where typ is an interface has no methods.
if isPtr {
// don't look at under(typ) here - was bug (issue #47747)
if _, ok := typ.(*TypeParam); ok {
return
}
if _, ok := under(typ).(*Interface); ok {
return
}