diff --git a/src/go/types/call.go b/src/go/types/call.go index 4e5b98a12e..bcd569e82f 100644 --- a/src/go/types/call.go +++ b/src/go/types/call.go @@ -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) diff --git a/src/go/types/sizeof_test.go b/src/go/types/sizeof_test.go index b8f191ee86..8f5f42b415 100644 --- a/src/go/types/sizeof_test.go +++ b/src/go/types/sizeof_test.go @@ -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}, diff --git a/src/go/types/type.go b/src/go/types/type.go index 03c1586774..459ce9e72c 100644 --- a/src/go/types/type.go +++ b/src/go/types/type.go @@ -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