Skip to content

Commit ca17bda

Browse files
griesemergopherbot
authored andcommitted
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>
1 parent 4b77847 commit ca17bda

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/cmd/compile/internal/types2/expr.go

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ var op2str2 = [...]string{
131131
// If typ is a type parameter, underIs returns the result of typ.underIs(f).
132132
// Otherwise, underIs returns the result of f(under(typ)).
133133
func underIs(typ Type, f func(Type) bool) bool {
134+
typ = Unalias(typ)
134135
if tpar, _ := typ.(*TypeParam); tpar != nil {
135136
return tpar.underIs(f)
136137
}

src/go/types/expr.go

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ var op2str2 = [...]string{
117117
// If typ is a type parameter, underIs returns the result of typ.underIs(f).
118118
// Otherwise, underIs returns the result of f(under(typ)).
119119
func underIs(typ Type, f func(Type) bool) bool {
120+
typ = Unalias(typ)
120121
if tpar, _ := typ.(*TypeParam); tpar != nil {
121122
return tpar.underIs(f)
122123
}

src/internal/types/testdata/fixedbugs/issue67547.go

+6
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ func _[P string]() {
2020
var s A
2121
copy(t, s) // don't report an error for s
2222
}
23+
24+
func _[P map[int]int]() {
25+
type A = P
26+
var m A
27+
clear(m) // don't report an error for m
28+
}

0 commit comments

Comments
 (0)