go/types, types2: move xlist next to targs in Checker.arguments signature

targs and xlist belong together (xlist contains the type expressions for
each of the type arguments).

Also, in builtins.go, rename xlist to alist2 to avoid some confusion.

Preparation for adding more parameters to the Checker.arguments signature.

Change-Id: I960501cfd2b88410ec0d581a6520a4e80fcdc56a
Reviewed-on: https://go-review.googlesource.com/c/go/+/494121
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2023-05-10 09:06:33 -07:00 committed by Gopher Robot
parent 95c4f320d5
commit 945a2b17f3
4 changed files with 12 additions and 12 deletions

View file

@ -133,17 +133,17 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// check general case by creating custom signature
sig := makeSig(S, S, NewSlice(T)) // []T required for variadic signature
sig.variadic = true
var xlist []*operand
var alist2 []*operand
// convert []operand to []*operand
for i := range alist {
xlist = append(xlist, &alist[i])
alist2 = append(alist2, &alist[i])
}
for i := len(alist); i < nargs; i++ {
var x operand
arg(&x, i)
xlist = append(xlist, &x)
alist2 = append(alist2, &x)
}
check.arguments(call, sig, nil, xlist, nil) // discard result (we know the result type)
check.arguments(call, sig, nil, nil, alist2) // discard result (we know the result type)
// ok to continue even if check.arguments reported errors
x.mode = value

View file

@ -325,7 +325,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
// evaluate arguments
args := check.genericExprList(call.ArgList)
sig = check.arguments(call, sig, targs, args, xlist)
sig = check.arguments(call, sig, targs, xlist, args)
if wasGeneric && sig.TypeParams().Len() == 0 {
// update the recorded type of call.Fun to its instantiated type
@ -419,7 +419,7 @@ func (check *Checker) genericExprList(elist []syntax.Expr) []*operand {
}
// xlist is the list of type argument expressions supplied in the source code.
func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []Type, args []*operand, xlist []syntax.Expr) (rsig *Signature) {
func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []Type, xlist []syntax.Expr, args []*operand) (rsig *Signature) {
rsig = sig
// TODO(gri) try to eliminate this extra verification loop

View file

@ -134,17 +134,17 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
// check general case by creating custom signature
sig := makeSig(S, S, NewSlice(T)) // []T required for variadic signature
sig.variadic = true
var xlist []*operand
var alist2 []*operand
// convert []operand to []*operand
for i := range alist {
xlist = append(xlist, &alist[i])
alist2 = append(alist2, &alist[i])
}
for i := len(alist); i < nargs; i++ {
var x operand
arg(&x, i)
xlist = append(xlist, &x)
alist2 = append(alist2, &x)
}
check.arguments(call, sig, nil, xlist, nil) // discard result (we know the result type)
check.arguments(call, sig, nil, nil, alist2) // discard result (we know the result type)
// ok to continue even if check.arguments reported errors
x.mode = value

View file

@ -330,7 +330,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
// evaluate arguments
args := check.genericExprList(call.Args)
sig = check.arguments(call, sig, targs, args, xlist)
sig = check.arguments(call, sig, targs, xlist, args)
if wasGeneric && sig.TypeParams().Len() == 0 {
// Update the recorded type of call.Fun to its instantiated type.
@ -424,7 +424,7 @@ func (check *Checker) genericExprList(elist []ast.Expr) []*operand {
}
// xlist is the list of type argument expressions supplied in the source code.
func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, targs []Type, args []*operand, xlist []ast.Expr) (rsig *Signature) {
func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, targs []Type, xlist []ast.Expr, args []*operand) (rsig *Signature) {
rsig = sig
// TODO(gri) try to eliminate this extra verification loop