diff options
author | Rob Findley <rfindley@google.com> | 2021-02-16 19:56:38 -0500 |
---|---|---|
committer | Robert Findley <rfindley@google.com> | 2021-02-18 20:38:41 +0000 |
commit | 5ecb9a788716be799d73c5d8192368ecb9557d48 (patch) | |
tree | c7909d74c3a563816463aa0728fd0904a905b2bc /src/go/types/expr.go | |
parent | 7b679617f3bb532fe65d8e83365b9f1f41b01b00 (diff) | |
download | go-5ecb9a788716be799d73c5d8192368ecb9557d48.tar.gz go-5ecb9a788716be799d73c5d8192368ecb9557d48.zip |
[dev.typeparams] go/types: use a new ast.ListExpr for multi-type instances
Modify go/parser to consistently represent type instantiation as an
ast.IndexExpr, rather than use an ast.CallExpr (with Brackets:true) for
instantiations with multiple type parameters. To enable this, introduce
a new ast expr type: ListExpr.
This brings go/types in line with types2, with the exception of a small
change to funcInst to eliminate redundant errors if values are
erroneously used as types. In a subsequent CL, call.go and expr.go will
be marked as reviewed.
This also catches some type instance syntax using '()' that was
previously accepted incorrectly. Tests are updated accordingly.
Change-Id: I30cd0181c7608f1be7486a9a8b63df993b412e85
Reviewed-on: https://go-review.googlesource.com/c/go/+/293010
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/go/types/expr.go')
-rw-r--r-- | src/go/types/expr.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/go/types/expr.go b/src/go/types/expr.go index 45cf8c6b41..77807e3b5b 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -1459,7 +1459,8 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { if x.mode == value { if sig := asSignature(x.typ); sig != nil && len(sig.tparams) > 0 { - return check.call(x, nil, e) + check.funcInst(x, e) + return expression } } @@ -1739,7 +1740,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { x.typ = T case *ast.CallExpr: - return check.call(x, e, e) + return check.call(x, e) case *ast.StarExpr: check.exprOrType(x, e.X) |