mirror of
https://github.com/golang/go.git
synced 2025-10-23 21:13:20 +00:00
[dev.typeparams] Parse a generic type arg for generic function call
Will now run "go tool compile -G=2 -W=2" on a simple generic function with one type parameter and a call to that function with one explicit type argument. Next change will handle multiple type arguments. Change-Id: Ia7d17ea2a02bf99bd50e673ac80ae4aad4c48440 Reviewed-on: https://go-review.googlesource.com/c/go/+/288432 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com>
This commit is contained in:
parent
0aafd69124
commit
13a7412983
4 changed files with 80 additions and 12 deletions
|
|
@ -93,9 +93,16 @@ func (g *irgen) expr0(typ types2.Type, expr syntax.Expr) ir.Node {
|
|||
case *syntax.AssertExpr:
|
||||
return Assert(pos, g.expr(expr.X), g.typeExpr(expr.Type))
|
||||
case *syntax.CallExpr:
|
||||
return Call(pos, g.expr(expr.Fun), g.exprs(expr.ArgList), expr.HasDots)
|
||||
def := g.info.Inferred[expr]
|
||||
if len(def.Targs) > 0 {
|
||||
panic("Inferred type arguments not handled yet")
|
||||
}
|
||||
return Call(pos, g.typ(typ), g.expr(expr.Fun), g.exprs(expr.ArgList), expr.HasDots)
|
||||
case *syntax.IndexExpr:
|
||||
return Index(pos, g.expr(expr.X), g.expr(expr.Index))
|
||||
if _, ok := expr.Index.(*syntax.ListExpr); ok {
|
||||
panic("more than one type argument")
|
||||
}
|
||||
return Index(pos, g.typ(typ), g.expr(expr.X), g.expr(expr.Index))
|
||||
case *syntax.ParenExpr:
|
||||
return g.expr(expr.X) // skip parens; unneeded after parse+typecheck
|
||||
case *syntax.SelectorExpr:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue