go/types, types2: underIs must consider Alias types

Fixes regression from Go 1.22.

For #67547.

Change-Id: I012681c7b8b01b02018b313dd3804690bc7aeed1
Reviewed-on: https://go-review.googlesource.com/c/go/+/587158
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Robert Griesemer 2024-05-21 15:16:25 -07:00 committed by Gopher Robot
parent 4b778470f8
commit ca17bda856
3 changed files with 8 additions and 0 deletions

View File

@ -131,6 +131,7 @@ var op2str2 = [...]string{
// If typ is a type parameter, underIs returns the result of typ.underIs(f).
// Otherwise, underIs returns the result of f(under(typ)).
func underIs(typ Type, f func(Type) bool) bool {
typ = Unalias(typ)
if tpar, _ := typ.(*TypeParam); tpar != nil {
return tpar.underIs(f)
}

View File

@ -117,6 +117,7 @@ var op2str2 = [...]string{
// If typ is a type parameter, underIs returns the result of typ.underIs(f).
// Otherwise, underIs returns the result of f(under(typ)).
func underIs(typ Type, f func(Type) bool) bool {
typ = Unalias(typ)
if tpar, _ := typ.(*TypeParam); tpar != nil {
return tpar.underIs(f)
}

View File

@ -20,3 +20,9 @@ func _[P string]() {
var s A
copy(t, s) // don't report an error for s
}
func _[P map[int]int]() {
type A = P
var m A
clear(m) // don't report an error for m
}