]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/compile/internal/types2/signature.go
go/types, types2: introduce _Alias type node
[gostls13.git] / src / cmd / compile / internal / types2 / signature.go
index 61c6721f806777fa0c70897b19d78c92f0fb234c..f876b16c8f6b4c47a3c0195b0a80d32c7e5084c3 100644 (file)
@@ -136,7 +136,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
                                // Also: Don't report an error via genericType since it will be reported
                                //       again when we type-check the signature.
                                // TODO(gri) maybe the receiver should be marked as invalid instead?
-                               if recv, _ := check.genericType(rname, nil).(*Named); recv != nil {
+                               if recv := asNamed(check.genericType(rname, nil)); recv != nil {
                                        recvTParams = recv.TypeParams().list()
                                }
                        }
@@ -154,7 +154,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
                        } else if len(tparams) < len(recvTParams) {
                                // Reporting an error here is a stop-gap measure to avoid crashes in the
                                // compiler when a type parameter/argument cannot be inferred later. It
-                               // may lead to follow-on errors (see issues #51339, #51343).
+                               // may lead to follow-on errors (see issues go.dev/issue/51339, go.dev/issue/51343).
                                // TODO(gri) find a better solution
                                got := measure(len(tparams), "type parameter")
                                check.errorf(recvPar, BadRecv, "got %s, but receiver base type declares %d", got, len(recvTParams))
@@ -204,17 +204,18 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
                sig.recv = recv
 
                // Delay validation of receiver type as it may cause premature expansion
-               // of types the receiver type is dependent on (see issues #51232, #51233).
+               // of types the receiver type is dependent on (see issues go.dev/issue/51232, go.dev/issue/51233).
                check.later(func() {
                        // spec: "The receiver type must be of the form T or *T where T is a type name."
                        rtyp, _ := deref(recv.typ)
-                       if rtyp == Typ[Invalid] {
+                       atyp := _Unalias(rtyp)
+                       if !isValid(atyp) {
                                return // error was reported before
                        }
                        // spec: "The type denoted by T is called the receiver base type; it must not
                        // be a pointer or interface type and it must be declared in the same package
                        // as the method."
-                       switch T := rtyp.(type) {
+                       switch T := atyp.(type) {
                        case *Named:
                                // The receiver type may be an instantiated type referred to
                                // by an alias (which cannot have receiver parameters for now).