1
0
mirror of https://github.com/golang/go synced 2024-11-19 05:14:50 -07:00

go/types: review of call.go

The changes from the (reviewed) dev.regabi copy of call.go can be seen
by comparing patchset 1 and 4. The actual changes are removing the
"// REVIEW INCOMPLETE" marker, deleting some leftover handling of type
instantiation in Checker.call, and adding a comment that exprOrTypeList
should be refactored.

I started to refactor exprOrTypeList, but thought it best to mark this
code as reviewed before diverging from types2.

Change-Id: Icf7fbff5a8def49c5f1781472fd7ba7b73dd9a9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/295531
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>
This commit is contained in:
Rob Findley 2021-02-23 12:01:26 -05:00 committed by Robert Findley
parent 35b80eac7d
commit 26001d109e

View File

@ -1,4 +1,3 @@
// REVIEW INCOMPLETE
// Copyright 2013 The Go Authors. All rights reserved. // Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
@ -114,19 +113,9 @@ func (check *Checker) call(x *operand, call *ast.CallExpr) exprKind {
return statement return statement
case typexpr: case typexpr:
// conversion or type instantiation // conversion
T := x.typ T := x.typ
x.mode = invalid x.mode = invalid
if isGeneric(T) {
// type instantiation
x.typ = check.typ(call)
if x.typ != Typ[Invalid] {
x.mode = typexpr
}
return expression
}
// conversion
switch n := len(call.Args); n { switch n := len(call.Args); n {
case 0: case 0:
check.errorf(inNode(call, call.Rparen), _WrongArgCount, "missing argument in conversion to %s", T) check.errorf(inNode(call, call.Rparen), _WrongArgCount, "missing argument in conversion to %s", T)
@ -217,6 +206,7 @@ func (check *Checker) call(x *operand, call *ast.CallExpr) exprKind {
// exprOrTypeList returns a list of operands and reports an error if the // exprOrTypeList returns a list of operands and reports an error if the
// list contains a mix of values and types (ignoring invalid operands). // list contains a mix of values and types (ignoring invalid operands).
// TODO(rFindley) Now we can split this into exprList and typeList.
func (check *Checker) exprOrTypeList(elist []ast.Expr) (xlist []*operand, ok bool) { func (check *Checker) exprOrTypeList(elist []ast.Expr) (xlist []*operand, ok bool) {
ok = true ok = true
@ -437,8 +427,6 @@ func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, args []*oper
} }
// check arguments // check arguments
// TODO(gri) Possible optimization (may be tricky): We could avoid
// checking arguments from which we inferred type arguments.
for i, a := range args { for i, a := range args {
check.assignment(a, sigParams.vars[i].typ, check.sprintf("argument to %s", call.Fun)) check.assignment(a, sigParams.vars[i].typ, check.sprintf("argument to %s", call.Fun))
} }