Skip to content

Commit

Permalink
go/types: review of call.go
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
findleyr committed Feb 24, 2021
1 parent 35b80ea commit 26001d1
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/go/types/call.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// REVIEW INCOMPLETE
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
Expand Down Expand Up @@ -114,19 +113,9 @@ func (check *Checker) call(x *operand, call *ast.CallExpr) exprKind {
return statement

case typexpr:
// conversion or type instantiation
// conversion
T := x.typ
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 {
case 0:
check.errorf(inNode(call, call.Rparen), _WrongArgCount, "missing argument in conversion to %s", T)
Expand Down Expand Up @@ -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
// 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) {
ok = true

Expand Down Expand Up @@ -437,8 +427,6 @@ func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, args []*oper
}

// 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 {
check.assignment(a, sigParams.vars[i].typ, check.sprintf("argument to %s", call.Fun))
}
Expand Down

0 comments on commit 26001d1

Please sign in to comment.