diff options
author | Robert Griesemer <gri@golang.org> | 2023-10-12 18:32:09 -0700 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-10-13 15:10:45 +0000 |
commit | 64b6c481075b9fce611af37baf1cce0144455784 (patch) | |
tree | 12c8a4a1e6b5d2a2046713ab10cbf920f000bce7 | |
parent | ef6993f3270c95e1158b11d9fc1a047528b34da6 (diff) | |
download | go-64b6c481075b9fce611af37baf1cce0144455784.tar.gz go-64b6c481075b9fce611af37baf1cce0144455784.zip |
[release-branch.go1.21] go/types, types2: don't use generics
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>
-rw-r--r-- | src/cmd/compile/internal/types2/call.go | 3 | ||||
-rw-r--r-- | src/cmd/compile/internal/types2/predicates.go | 6 | ||||
-rw-r--r-- | src/go/types/call.go | 3 | ||||
-rw-r--r-- | src/go/types/predicates.go | 6 |
4 files changed, 4 insertions, 14 deletions
diff --git a/src/cmd/compile/internal/types2/call.go b/src/cmd/compile/internal/types2/call.go index 4d7d9b6634..24f54c36cf 100644 --- a/src/cmd/compile/internal/types2/call.go +++ b/src/cmd/compile/internal/types2/call.go @@ -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 diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index f4203789f0..13a3bf8af5 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -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 -} diff --git a/src/go/types/call.go b/src/go/types/call.go index fd0de54e25..f00290a74f 100644 --- a/src/go/types/call.go +++ b/src/go/types/call.go @@ -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 diff --git a/src/go/types/predicates.go b/src/go/types/predicates.go index a78191871f..b821b584c1 100644 --- a/src/go/types/predicates.go +++ b/src/go/types/predicates.go @@ -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 -} |