Closed griesemer closed 1 day ago
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Just to double check, the goal is to return an error and not panic right?
Renaming each independent binding for type parameters to a distinct name:
package p
type T[P any] struct{}
type A[Q any] = T[Q]
func (A[R]) m() {} // <- should not be accepted as there is no R to instantiate A[R].
Just discussed with @ianlancetaylor . We concluded that we should not permit methods that have a generic alias as receiver type. We already do not allow methods that have a non-generic alias receiver but where the aliased type is an (instantiated) generic type.
Change https://go.dev/cl/629080 mentions this issue: go/types, types2: disallow new methods on generic alias types
Change https://go.dev/cl/629577 mentions this issue: spec: document restrictions for method receivers that are aliases
Compiling
panics:
cc: @findleyr @timothy-king for visibility.