Skip to content

Complete type conversion support for type parameters #1242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 2, 2023
Merged
Prev Previous commit
Next Next commit
Correctly recognize type conversion expressions with multiple typepar…
…ams.

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.
  • Loading branch information
nevkontakte committed Nov 1, 2023
commit 4e6c8bcb00dcad6fb00fab06fc25dd034cf1afe8
7 changes: 7 additions & 0 deletions compiler/astutil/astutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ func IsTypeExpr(expr ast.Expr, info *types.Info) bool {
}
_, ok = info.Uses[ident].(*types.TypeName)
return ok
case *ast.IndexListExpr:
ident, ok := e.X.(*ast.Ident)
if !ok {
return false
}
_, ok = info.Uses[ident].(*types.TypeName)
return ok
case *ast.ParenExpr:
return IsTypeExpr(e.X, info)
default:
Expand Down
2 changes: 1 addition & 1 deletion tests/gorepo/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ var knownFails = map[string]failReason{
"typeparam/issue48453.go": {category: generics, desc: "make() doesn't support generic slice types"},
"typeparam/issue49295.go": {category: generics, desc: "len() doesn't support generic pointer to array types"},
"typeparam/issue50193.go": {category: generics, desc: "invalid print format for complex numbers"},
"typeparam/issue51303.go": {category: generics, desc: "missing support for conversion into a parameterized type"},
"typeparam/issue51303.go": {category: generics, desc: "missing support for range over type parameter"},
"typeparam/issue51522a.go": {category: generics, desc: "missing support for the comparable type constraint"},
"typeparam/issue51522b.go": {category: generics, desc: "missing support for the comparable type constraint"},
"typeparam/list.go": {category: generics, desc: "missing operator support for generic types"},
Expand Down