]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] go/types: make Interface.obj a *TypeName
authorRob Findley <rfindley@google.com>
Fri, 16 Jul 2021 14:33:59 +0000 (10:33 -0400)
committerRobert Findley <rfindley@google.com>
Fri, 16 Jul 2021 23:34:15 +0000 (23:34 +0000)
This is a straightforward port of CL 332011 to go/types.

Change-Id: I682791886c8496c52094f3688e36934afbd7a241
Reviewed-on: https://go-review.googlesource.com/c/go/+/335035
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/call.go
src/go/types/sizeof_test.go
src/go/types/type.go

index 4e5b98a12e5ff2aea8c0d9bc7ffdd13c33083d39..bcd569e82f162d60287b80f00e42bcf30c130c7b 100644 (file)
@@ -482,11 +482,10 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
                        var why string
                        if tpar := asTypeParam(x.typ); tpar != nil {
                                // Type parameter bounds don't specify fields, so don't mention "field".
-                               switch obj := tpar.Bound().obj.(type) {
-                               case nil:
+                               if tname := tpar.Bound().obj; tname != nil {
+                                       why = check.sprintf("interface %s has no method %s", tname.name, sel)
+                               } else {
                                        why = check.sprintf("type bound for %s has no method %s", x.typ, sel)
-                               case *TypeName:
-                                       why = check.sprintf("interface %s has no method %s", obj.name, sel)
                                }
                        } else {
                                why = check.sprintf("type %s has no field or method %s", x.typ, sel)
index b8f191ee867287fcd23506ec84b02e87c8bac43b..8f5f42b4150409cc8dd370802b4547ce00c314ad 100644 (file)
@@ -27,7 +27,7 @@ func TestSizeof(t *testing.T) {
                {Tuple{}, 12, 24},
                {Signature{}, 44, 88},
                {Union{}, 24, 48},
-               {Interface{}, 44, 88},
+               {Interface{}, 40, 80},
                {Map{}, 16, 32},
                {Chan{}, 12, 24},
                {Named{}, 84, 160},
index 03c15867746d088341b9cedc071f952e4c6f2ea8..459ce9e72c1620ef409ee1097455383c156bfddb 100644 (file)
@@ -258,7 +258,7 @@ func (s *Signature) Variadic() bool { return s.variadic }
 
 // An Interface represents an interface type.
 type Interface struct {
-       obj       Object       // type name object defining this interface; or nil (for better error messages)
+       obj       *TypeName    // type name object defining this interface; or nil (for better error messages)
        methods   []*Func      // ordered list of explicitly declared methods
        embeddeds []Type       // ordered list of explicitly embedded elements
        embedPos  *[]token.Pos // positions of embedded elements; or nil (for error messages) - use pointer to save space