diff options
| author | Robert Griesemer <gri@golang.org> | 2021-08-30 20:30:25 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2021-08-31 16:43:46 +0000 |
| commit | 68152359fdd45e8d51aaaec64075aad4ff8f68b2 (patch) | |
| tree | a94c32d5009e0ecdad3d38544bdc739392e4167a /test/typeparam | |
| parent | 605d1aaea26ef775369a3d1da6cf53f2a7b1e640 (diff) | |
| download | go-68152359fdd45e8d51aaaec64075aad4ff8f68b2.tar.xz | |
cmd/compile/internal/types2: disallow aliases for generic types
The existing approach (alias name stands for generic type name)
is an exception: it's the only place where a generic type could
be used without explicit instantiation. The correct solution is
currently under discussion (see proposal issue #46477).
This CL requires that the RHS of an alias type declaration be
an instantiated non-generic type. If #46477 is accepted, the
implementation will require proper representation of alias
types.
Change-Id: Ie85b923213a64f39837e56e38e14757458272b93
Reviewed-on: https://go-review.googlesource.com/c/go/+/346294
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'test/typeparam')
| -rw-r--r-- | test/typeparam/aliasimp.dir/main.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/test/typeparam/aliasimp.dir/main.go b/test/typeparam/aliasimp.dir/main.go index 221a6c758d..24ce95472f 100644 --- a/test/typeparam/aliasimp.dir/main.go +++ b/test/typeparam/aliasimp.dir/main.go @@ -10,16 +10,18 @@ type R[T any] struct { F T } -type S = R +// type S = R // disallowed for now type Sint = R[int] -type Simp = a.Rimp +// type Simp = a.Rimp // disallowed for now -type SimpString Simp[string] +// type SimpString Simp[string] // disallowed for now +type SimpString a.Rimp[string] func main() { - var s S[int] + // var s S[int] // disallowed for now + var s R[int] if s.F != 0 { panic(s.F) } @@ -27,7 +29,8 @@ func main() { if s2.F != 0 { panic(s2.F) } - var s3 Simp[string] + // var s3 Simp[string] // disallowed for now + var s3 a.Rimp[string] if s3.F != "" { panic(s3.F) } |
