Skip to content

Commit 34cf5f6

Browse files
findleyrgopherbot
authored andcommitted
go/types: add test for interface method field type
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 <[email protected]> Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Robert Findley <[email protected]>
1 parent 6e618cd commit 34cf5f6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ func TestTypesInfo(t *testing.T) {
358358
// go.dev/issue/47895
359359
{`package p; import "unsafe"; type S struct { f int }; var s S; var _ = unsafe.Offsetof(s.f)`, `s.f`, `int`},
360360

361+
// go.dev/issue/74303. Note that interface field types are synthetic, so
362+
// even though `func()` doesn't appear in the source, it appears in the
363+
// syntax tree.
364+
{`package p; type T interface { M(int) }`, `func(int)`, `func(int)`},
365+
361366
// go.dev/issue/50093
362367
{`package u0a; func _[_ interface{int}]() {}`, `int`, `int`},
363368
{`package u1a; func _[_ interface{~int}]() {}`, `~int`, `~int`},

src/go/types/api_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ func TestTypesInfo(t *testing.T) {
364364
// go.dev/issue/47895
365365
{`package p; import "unsafe"; type S struct { f int }; var s S; var _ = unsafe.Offsetof(s.f)`, `s.f`, `int`},
366366

367+
// go.dev/issue/74303. Note that interface field types are synthetic, so
368+
// even though `func()` doesn't appear in the source, it appears in the
369+
// syntax tree.
370+
{`package p; type T interface { M(int) }`, `func(int)`, `func(int)`},
371+
367372
// go.dev/issue/50093
368373
{`package u0a; func _[_ interface{int}]() {}`, `int`, `int`},
369374
{`package u1a; func _[_ interface{~int}]() {}`, `~int`, `~int`},

0 commit comments

Comments
 (0)