]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: disallow new methods on generic alias and instantiated types
authorRobert Griesemer <gri@golang.org>
Mon, 18 Nov 2024 20:45:17 +0000 (12:45 -0800)
committerGopher Robot <gobot@golang.org>
Wed, 20 Nov 2024 20:03:55 +0000 (20:03 +0000)
commit91af7119cd33e59a04d96073bc0f40b588938163
treece09ccacbb139c5223dd7b14280efe7365cb589e
parentd69e6f63c349741a450e9de9585ad555babefad4
go/types, types2: disallow new methods on generic alias and instantiated types

If the receiver is an alias declaring type parameters, report
an error and ensure that the receiver type remains invalid.
Collect type parameters etc. as before but do not attempt to
find their constraints or instantiate the receiver type.
The constraints of the type parameters will be invalid by
default. The receiver type will not be (lazily) instantiated
which causes problems with existing invariants.

If a receiver denotes an instantiated (alias or defined) type,
report an error and ensure that the receiver type remains invalid.

While at it, add more comments and bring go/types and types2
closer together where there were differences.

Fixes #70417.

Change-Id: I87ef0b42d2f70464664cacc410f4b7eb1c994241
Reviewed-on: https://go-review.googlesource.com/c/go/+/629080
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/compile/internal/types2/resolver.go
src/cmd/compile/internal/types2/signature.go
src/go/types/resolver.go
src/go/types/signature.go
src/internal/types/testdata/fixedbugs/issue47968.go
src/internal/types/testdata/fixedbugs/issue70417.go [new file with mode: 0644]