]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: underIs must consider Alias types
authorRobert Griesemer <gri@golang.org>
Tue, 21 May 2024 22:16:25 +0000 (15:16 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 21 May 2024 22:39:35 +0000 (22:39 +0000)
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>

src/cmd/compile/internal/types2/expr.go
src/go/types/expr.go
src/internal/types/testdata/fixedbugs/issue67547.go

index b2ff262762acd17a5b630ba16e635fe774e221e9..da676f47da141900331a0b5adae1da2957326023 100644 (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)
        }
index ef61e2cc40dec6b60d9f1948a893d151963a69d3..474db75cc810912c62cdcee8e2c6e6a23c43a99f 100644 (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)
        }
index b95be4faeb22ea38ed2fffd3c1e8eaeb0f131658..930692aa57ae11c931e686ff5cf56a93daed0fa8 100644 (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
+}