aboutsummaryrefslogtreecommitdiff
path: root/src/go/types/expr.go
diff options
context:
space:
mode:
authorRob Findley <rfindley@google.com>2021-04-27 16:54:58 -0400
committerRobert Findley <rfindley@google.com>2021-04-28 17:11:15 +0000
commitf893f35d9f7acc3bad32efeac693a44849b5e895 (patch)
tree8c1b402987af957765408578fe8f0dced6384031 /src/go/types/expr.go
parent5b328c4a2fbae10ec10d233d691435fe0295fc39 (diff)
downloadgo-f893f35d9f7acc3bad32efeac693a44849b5e895.tar.gz
go-f893f35d9f7acc3bad32efeac693a44849b5e895.zip
go/types: split out function instantiation from index expr
This is a port of CL 308371 to go/types. The only meaningful change from that CL is to use explicit return values in Checker.indexExpr, which I felt was more readable. I made the same change in types2 to keep them in sync Change-Id: I3380c03fe49d3bf4167cadad305abe942785af19 Reviewed-on: https://go-review.googlesource.com/c/go/+/314432 Trust: Robert Findley <rfindley@google.com> 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.go32
1 files changed, 5 insertions, 27 deletions
diff --git a/src/go/types/expr.go b/src/go/types/expr.go
index bdab7d9aa6..4055cdd080 100644
--- a/src/go/types/expr.go
+++ b/src/go/types/expr.go
@@ -1027,31 +1027,7 @@ func (check *Checker) rawExpr(x *operand, e ast.Expr, hint Type) exprKind {
}
kind := check.exprInternal(x, e, hint)
-
- // convert x into a user-friendly set of values
- // TODO(gri) this code can be simplified
- var typ Type
- var val constant.Value
- switch x.mode {
- case invalid:
- typ = Typ[Invalid]
- case novalue:
- typ = (*Tuple)(nil)
- case constant_:
- typ = x.typ
- val = x.val
- default:
- typ = x.typ
- }
- assert(x.expr != nil && typ != nil)
-
- if isUntyped(typ) {
- // delay type and value recording until we know the type
- // or until the end of type checking
- check.rememberUntyped(x.expr, false, x.mode, typ.(*Basic), val)
- } else {
- check.recordTypeAndValue(e, x.mode, typ, val)
- }
+ check.record(x)
return kind
}
@@ -1340,7 +1316,9 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
check.selector(x, e)
case *ast.IndexExpr:
- check.indexExpr(x, e)
+ if check.indexExpr(x, e) {
+ check.funcInst(x, e)
+ }
if x.mode == invalid {
goto Error
}
@@ -1378,7 +1356,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
x.typ = T
case *ast.CallExpr:
- return check.call(x, e)
+ return check.callExpr(x, e)
case *ast.StarExpr:
check.exprOrType(x, e.X)