The unification code has "early exits" when the compared
types are pointer-identical.
Because of Alias nodes, we cannot simply compare x == y but we
must compare Unalias(x) == Unalias(y). Still, in the common case
there are no aliases, so as a minor optimization we write:
x == y || Unalias(x) == Unalias(y)
to test whether x and y are (pointer-) identical.
Add the missing Unalias calls in the place where we forgot them.
Fixes #67872.
Change-Id: Ia26ffe7205b0417fc698287a4aeb1c900d30cc0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/591975
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
// that is a type parameter.
assert(!isTypeParam(y))
// x and y may be identical now
- if x == y {
+ if x == y || Unalias(x) == Unalias(y) {
return true
}
}
// that is a type parameter.
assert(!isTypeParam(y))
// x and y may be identical now
- if x == y {
+ if x == y || Unalias(x) == Unalias(y) {
return true
}
}
--- /dev/null
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type A = uint8
+type E uint8
+
+func f[P ~A](P) {}
+
+func g(e E) {
+ f(e)
+}