]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.21] go/types, types2: don't use generics
authorRobert Griesemer <gri@golang.org>
Fri, 13 Oct 2023 01:32:09 +0000 (18:32 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 13 Oct 2023 15:10:45 +0000 (15:10 +0000)
This fixes cherry-pick CL 531998.

For #63339.

Change-Id: I6dac0909ca85d68684ce36025284d25db32e0b15
Reviewed-on: https://go-review.googlesource.com/c/go/+/535135
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/predicates.go
src/go/types/call.go
src/go/types/predicates.go

index 4d7d9b6634019846475164e7bac41507ad595c8c..24f54c36cf37c214cdab46c6d1686dc3565f7877 100644 (file)
@@ -575,7 +575,8 @@ func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []T
                                // Before we change the type (type parameter renaming, below), make
                                // a clone of it as otherwise we implicitly modify the object's type
                                // (go.dev/issues/63260).
-                               asig = clone(asig)
+                               clone := *asig
+                               asig = &clone
                                // Rename type parameters for cases like f(g, g); this gives each
                                // generic function argument a unique type identity (go.dev/issues/59956).
                                // TODO(gri) Consider only doing this if a function argument appears
index f4203789f05ff2518bca49360a6ce70daaf68495..13a3bf8af5b5b43fd42f83abbc43a2ea3134c711 100644 (file)
@@ -530,9 +530,3 @@ func maxType(x, y Type) Type {
        }
        return nil
 }
-
-// clone makes a "flat copy" of *p and returns a pointer to the copy.
-func clone[P *T, T any](p P) P {
-       c := *p
-       return &c
-}
index fd0de54e25d3552c11145a7e577e157b341c245f..f00290a74f4ea7a10d79e3b4a7136165dd708b9f 100644 (file)
@@ -577,7 +577,8 @@ func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, targs []Type
                                // Before we change the type (type parameter renaming, below), make
                                // a clone of it as otherwise we implicitly modify the object's type
                                // (go.dev/issues/63260).
-                               asig = clone(asig)
+                               clone := *asig
+                               asig = &clone
                                // Rename type parameters for cases like f(g, g); this gives each
                                // generic function argument a unique type identity (go.dev/issues/59956).
                                // TODO(gri) Consider only doing this if a function argument appears
index a78191871f68465c4510591e0bce8c1d2352af55..b821b584c151156634dad0a2633139e9f2cf35ed 100644 (file)
@@ -532,9 +532,3 @@ func maxType(x, y Type) Type {
        }
        return nil
 }
-
-// clone makes a "flat copy" of *p and returns a pointer to the copy.
-func clone[P *T, T any](p P) P {
-       c := *p
-       return &c
-}