]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: move xlist next to targs in Checker.arguments signature
authorRobert Griesemer <gri@golang.org>
Wed, 10 May 2023 16:06:33 +0000 (09:06 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 10 May 2023 16:34:03 +0000 (16:34 +0000)
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>
src/cmd/compile/internal/types2/builtins.go
src/cmd/compile/internal/types2/call.go
src/go/types/builtins.go
src/go/types/call.go

index 3dcef64146fb0d8f2228e410ad1b87f647246c92..15769ead4b28589751967eb274a4cf837e255383 100644 (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
index 54f6c7ee48f96e131b5f5159fc78dae934666ecb..075dfd1efa419e785764db1dba2045bc59f0efc6 100644 (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
index 361a76021167cdd1a5f60b18b72f2a279cad20e8..e4b00cd75716d1d71beea2be4e1b408c2a3139fa 100644 (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
index 5877a345df0b218fad245dd9997346628f2dd730..640910424e98c6ef843789794636aa2965ec0ecc 100644 (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