From 64b6c481075b9fce611af37baf1cce0144455784 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 12 Oct 2023 18:32:09 -0700 Subject: [PATCH] [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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Alan Donovan --- src/cmd/compile/internal/types2/call.go | 3 ++- src/cmd/compile/internal/types2/predicates.go | 6 ------ src/go/types/call.go | 3 ++- 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 -} -- 2.48.1