Skip to content

Commit 2faeebf

Browse files
committed
[dev.go2go] go/types: permit alias to generic type
Fixes #39768. Change-Id: I68c8fbec5adc50e448dabe90b212ef147a384a06 Reviewed-on: https://go-review.googlesource.com/c/go/+/239387 Reviewed-by: Robert Griesemer <[email protected]>
1 parent 6ca930a commit 2faeebf

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/go/types/check_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ var tests = [][]string{
131131
{"fixedbugs/issue39711.go2"},
132132
{"fixedbugs/issue39723.go2"},
133133
{"fixedbugs/issue39755.go2"},
134+
{"fixedbugs/issue39768.go2"},
134135
}
135136

136137
var fset = token.NewFileSet()

src/go/types/decl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) {
562562
}
563563

564564
obj.typ = Typ[Invalid]
565-
obj.typ = check.typ(tdecl.Type)
565+
obj.typ = check.anyType(tdecl.Type)
566566

567567
} else {
568568
// defined type declaration

src/go/types/fixedbugs/issue39768.go2

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2020 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package p
6+
7+
type T(type P) P
8+
type A = T
9+
var x A(int)
10+
var _ A /* ERROR cannot use generic type */
11+
12+
type B = T(int)
13+
var y B = x
14+
var _ B /* ERROR not a generic type */ (int)
15+
16+
// test case from issue
17+
18+
type Vector(type T) []T
19+
type VectorAlias = Vector
20+
var v Vector(int)

0 commit comments

Comments
 (0)