diff --git a/src/go/types/check_test.go b/src/go/types/check_test.go index 4c32517fea..4065fb124e 100644 --- a/src/go/types/check_test.go +++ b/src/go/types/check_test.go @@ -131,6 +131,7 @@ var tests = [][]string{ {"fixedbugs/issue39711.go2"}, {"fixedbugs/issue39723.go2"}, {"fixedbugs/issue39755.go2"}, + {"fixedbugs/issue39768.go2"}, } var fset = token.NewFileSet() diff --git a/src/go/types/decl.go b/src/go/types/decl.go index 65b2e7be82..6dd97a03ad 100644 --- a/src/go/types/decl.go +++ b/src/go/types/decl.go @@ -562,7 +562,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) { } obj.typ = Typ[Invalid] - obj.typ = check.typ(tdecl.Type) + obj.typ = check.anyType(tdecl.Type) } else { // defined type declaration diff --git a/src/go/types/fixedbugs/issue39768.go2 b/src/go/types/fixedbugs/issue39768.go2 new file mode 100644 index 0000000000..dd28cbcbd2 --- /dev/null +++ b/src/go/types/fixedbugs/issue39768.go2 @@ -0,0 +1,20 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +type T(type P) P +type A = T +var x A(int) +var _ A /* ERROR cannot use generic type */ + +type B = T(int) +var y B = x +var _ B /* ERROR not a generic type */ (int) + +// test case from issue + +type Vector(type T) []T +type VectorAlias = Vector +var v Vector(int)