Skip to content

Commit

Permalink
go/types, types2: underIs must consider Alias types
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
griesemer authored and gopherbot committed May 21, 2024
1 parent 4b77847 commit ca17bda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cmd/compile/internal/types2/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions src/go/types/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 6 additions & 0 deletions src/internal/types/testdata/fixedbugs/issue67547.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit ca17bda

Please sign in to comment.