]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.23] unique: use TypeFor instead of TypeOf to get type in Make
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 21 Aug 2024 14:38:30 +0000 (14:38 +0000)
committerCherry Mui <cherryyz@google.com>
Wed, 21 Aug 2024 17:42:03 +0000 (17:42 +0000)
commit76346b354337c7011eddef040de7696307450e41
tree1c798f5157a1644f68b6f94bed3eef56c14bdb03
parent3c9340557cf1e13c2fe61c6b894ba284711dfb85
[release-branch.go1.23] unique: use TypeFor instead of TypeOf to get type in Make

Currently the first thing Make does it get the abi.Type of its argument,
and uses abi.TypeOf to do it. However, this has a problem for interface
types, since the type of the value stored in the interface value will
bleed through. This is a classic reflection mistake.

Fix this by implementing and using a generic TypeFor which matches
reflect.TypeFor. This gets the type of the type parameter, which is far
less ambiguous and error-prone.

For #68990.
Fixes #68992.

Change-Id: Idd8d9a1095ef017e9cd7c7779314f7d4034f01a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/607355
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 755c18ecdfe64df060be91fb669ca1a68527830b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/607435
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/internal/abi/type.go
src/unique/clone_test.go
src/unique/handle.go
src/unique/handle_test.go