Skip to content

Commit 4e6c8bc

Browse files
committed
Correctly recognize type conversion expressions with multiple typeparams.
Prior to this change expressions like `ss[T1, T2](val)` where `ss` is a parameterized type were not recognized as type conversion expressions due to use of the *ast.IndexListExpr node.
1 parent f2b91ba commit 4e6c8bc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/astutil/astutil.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ func IsTypeExpr(expr ast.Expr, info *types.Info) bool {
6060
}
6161
_, ok = info.Uses[ident].(*types.TypeName)
6262
return ok
63+
case *ast.IndexListExpr:
64+
ident, ok := e.X.(*ast.Ident)
65+
if !ok {
66+
return false
67+
}
68+
_, ok = info.Uses[ident].(*types.TypeName)
69+
return ok
6370
case *ast.ParenExpr:
6471
return IsTypeExpr(e.X, info)
6572
default:

tests/gorepo/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ var knownFails = map[string]failReason{
172172
"typeparam/issue48453.go": {category: generics, desc: "make() doesn't support generic slice types"},
173173
"typeparam/issue49295.go": {category: generics, desc: "len() doesn't support generic pointer to array types"},
174174
"typeparam/issue50193.go": {category: generics, desc: "invalid print format for complex numbers"},
175-
"typeparam/issue51303.go": {category: generics, desc: "missing support for conversion into a parameterized type"},
175+
"typeparam/issue51303.go": {category: generics, desc: "missing support for range over type parameter"},
176176
"typeparam/issue51522a.go": {category: generics, desc: "missing support for the comparable type constraint"},
177177
"typeparam/issue51522b.go": {category: generics, desc: "missing support for the comparable type constraint"},
178178
"typeparam/list.go": {category: generics, desc: "missing operator support for generic types"},

0 commit comments

Comments
 (0)