Skip to content

Commit

Permalink
go/types, types2: move xlist next to targs in Checker.arguments signa…
Browse files Browse the repository at this point in the history
…ture

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 <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Robert Griesemer <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
  • Loading branch information
griesemer authored and gopherbot committed May 10, 2023
1 parent 95c4f32 commit 945a2b1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/cmd/compile/internal/types2/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/types2/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/go/types/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/go/types/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 945a2b1

Please sign in to comment.