]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: collect methods with parenthesized receiver types
authorRobert Griesemer <gri@golang.org>
Thu, 14 Dec 2017 06:49:23 +0000 (22:49 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 14 Dec 2017 22:12:09 +0000 (22:12 +0000)
The existing code simply dropped them on the floor. Don't do that.

Fixes #23130.

Change-Id: I10f20e41f2c466a76519983253f87af7cf6d5e70
Reviewed-on: https://go-review.googlesource.com/83918
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/go/types/resolver.go
src/go/types/testdata/decls2b.src

index 7bcfaabcde078d5f5631c43923c1cdad4942822b..d03c1799af939428be819858b488699f99c349cb 100644 (file)
@@ -417,9 +417,9 @@ func (check *Checker) collectObjects() {
                                        // receiver name. They will be type-checked later, with regular
                                        // functions.
                                        if list := d.Recv.List; len(list) > 0 {
-                                               typ := list[0].Type
+                                               typ := unparen(list[0].Type)
                                                if ptr, _ := typ.(*ast.StarExpr); ptr != nil {
-                                                       typ = ptr.X
+                                                       typ = unparen(ptr.X)
                                                }
                                                if base, _ := typ.(*ast.Ident); base != nil && base.Name != "_" {
                                                        check.assocMethod(base.Name, obj)
index e7bc394762f8c5532490b09ad8924197f3afd734..8e82c6dcde13625dc6ec5dcf10d0978ebd1058b5 100644 (file)
@@ -63,3 +63,13 @@ func ((*T7)) m3() {}
 func (x *(T7),) m4() {}
 func (x (*(T7)),) m5() {}
 func (x ((*((T7)))),) m6() {}
+
+// Check that methods with parenthesized receiver are actually present (issue #23130).
+var (
+       _ = T7.m1
+       _ = T7.m2
+       _ = (*T7).m3
+       _ = (*T7).m4
+       _ = (*T7).m5
+       _ = (*T7).m6
+)
\ No newline at end of file