Skip to content

Commit 67295d6

Browse files
committed
go/types: collect methods with parenthesized receiver types
The existing code simply dropped them on the floor. Don't do that. Fixes golang#23130. Change-Id: I10f20e41f2c466a76519983253f87af7cf6d5e70 Reviewed-on: https://go-review.googlesource.com/83918 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
1 parent 75f0ad7 commit 67295d6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/go/types/resolver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ func (check *Checker) collectObjects() {
417417
// receiver name. They will be type-checked later, with regular
418418
// functions.
419419
if list := d.Recv.List; len(list) > 0 {
420-
typ := list[0].Type
420+
typ := unparen(list[0].Type)
421421
if ptr, _ := typ.(*ast.StarExpr); ptr != nil {
422-
typ = ptr.X
422+
typ = unparen(ptr.X)
423423
}
424424
if base, _ := typ.(*ast.Ident); base != nil && base.Name != "_" {
425425
check.assocMethod(base.Name, obj)

src/go/types/testdata/decls2b.src

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,13 @@ func ((*T7)) m3() {}
6363
func (x *(T7),) m4() {}
6464
func (x (*(T7)),) m5() {}
6565
func (x ((*((T7)))),) m6() {}
66+
67+
// Check that methods with parenthesized receiver are actually present (issue #23130).
68+
var (
69+
_ = T7.m1
70+
_ = T7.m2
71+
_ = (*T7).m3
72+
_ = (*T7).m4
73+
_ = (*T7).m5
74+
_ = (*T7).m6
75+
)

0 commit comments

Comments
 (0)