From e0b569842d0ef5deed5c455eef001b02aec27934 Mon Sep 17 00:00:00 2001
From: Robert Griesemer Point
.
-If the receiver base type is a generic type, the +If the receiver base type is a generic type, the receiver specification must declare corresponding type parameters for the method to use. This makes the receiver type parameters available to the method. Syntactically, this type parameter declaration looks like an @@ -3117,6 +3117,22 @@ func (p Pair[A, B]) Swap() Pair[B, A] { ⦠} // receiver declares A, B func (p Pair[First, _]) First() First { ⦠} // receiver declares First, corresponds to A in Pair +
+If the receiver type is denoted by (a pointer to) an alias, +the alias must not be generic and it must not denote an instantiated generic type, neither +directly nor indirectly via another alias, and irrespective of pointer indirections. +
+ ++type GPoint[P any] = Point +type HPoint = *GPoint[int] +type IPair = Pair[int, int] + +func (*GPoint[P]) Draw(P) { ⦠} // illegal: alias must not be generic +func (HPoint) Draw(P) { ⦠} // illegal: alias must not denote instantiated type GPoint[int] +func (*IPair) Second() int { ⦠} // illegal: alias must not denote instantiated type Pair[int, int] ++
-- 2.48.1