]> Cypherpunks repositories - gostls13.git/commit
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)
committerMichael Knyszek <mknyszek@google.com>
Wed, 21 Aug 2024 16:03:35 +0000 (16:03 +0000)
commit755c18ecdfe64df060be91fb669ca1a68527830b
treefda5208404d9938ccfcef24699766ae76c2b50f9
parentf38d42f2c4c6ad0d7cbdad5e1417cac3be2a5dcb
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.

Fixes #68990.

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>
src/internal/abi/type.go
src/unique/clone_test.go
src/unique/handle.go
src/unique/handle_test.go