]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: remove unneccesary tests in implements and lookup
authorRobert Findley <rfindley@google.com>
Thu, 18 Nov 2021 01:04:14 +0000 (20:04 -0500)
committerRobert Findley <rfindley@google.com>
Thu, 18 Nov 2021 14:08:10 +0000 (14:08 +0000)
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>
src/go/types/instantiate.go
src/go/types/lookup.go

index 737340d08665848008de9543ece5129adf2348f7..63b4a1ea4a3c0bc7a90ce4c9282a717ec0e45565 100644 (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)
index e3c43a94f7156d8dd22208be275550f58c0a9dd0..c787601a06512ae0644f1c4651a8625e26417126 100644 (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
                }