]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: add test for interface method field type
authorRob Findley <rfindley@google.com>
Tue, 24 Jun 2025 00:38:37 +0000 (00:38 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 24 Jun 2025 17:35:30 +0000 (10:35 -0700)
Add a test that would have detected the regression in #74303: interface
method fields should have a recorded type.

For #74303

Change-Id: Ide5df51cd71c38809c364bb4f95950163ecefb66
Reviewed-on: https://go-review.googlesource.com/c/go/+/683595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>

src/cmd/compile/internal/types2/api_test.go
src/go/types/api_test.go

index 44fb6afe9858ab5e2bcfe2f0118bce4b6b764309..0d3c8b8e3e5e0f692cad03dc144a4664c7e897e3 100644 (file)
@@ -358,6 +358,11 @@ func TestTypesInfo(t *testing.T) {
                // go.dev/issue/47895
                {`package p; import "unsafe"; type S struct { f int }; var s S; var _ = unsafe.Offsetof(s.f)`, `s.f`, `int`},
 
+               // go.dev/issue/74303. Note that interface field types are synthetic, so
+               // even though `func()` doesn't appear in the source, it appears in the
+               // syntax tree.
+               {`package p; type T interface { M(int) }`, `func(int)`, `func(int)`},
+
                // go.dev/issue/50093
                {`package u0a; func _[_ interface{int}]() {}`, `int`, `int`},
                {`package u1a; func _[_ interface{~int}]() {}`, `~int`, `~int`},
index f5a911306fb4b8e653453ea7d047f1802076d8fc..4396b8ae89d1db0a57790e0b11811c9b094b810a 100644 (file)
@@ -364,6 +364,11 @@ func TestTypesInfo(t *testing.T) {
                // go.dev/issue/47895
                {`package p; import "unsafe"; type S struct { f int }; var s S; var _ = unsafe.Offsetof(s.f)`, `s.f`, `int`},
 
+               // go.dev/issue/74303. Note that interface field types are synthetic, so
+               // even though `func()` doesn't appear in the source, it appears in the
+               // syntax tree.
+               {`package p; type T interface { M(int) }`, `func(int)`, `func(int)`},
+
                // go.dev/issue/50093
                {`package u0a; func _[_ interface{int}]() {}`, `int`, `int`},
                {`package u1a; func _[_ interface{~int}]() {}`, `~int`, `~int`},