// An Interface represents an interface type.
type Interface struct {
check *Checker // for error reporting; nil once type set is computed
- obj *TypeName // corresponding declared object; or nil (for better error messages)
methods []*Func // ordered list of explicitly declared methods
embeddeds []Type // ordered list of explicitly embedded elements
embedPos *[]syntax.Pos // positions of embedded elements; or nil (for error messages) - use pointer to save space
{Tuple{}, 12, 24},
{Signature{}, 28, 56},
{Union{}, 12, 24},
- {Interface{}, 44, 88},
+ {Interface{}, 40, 80},
{Map{}, 16, 32},
{Chan{}, 12, 24},
{Named{}, 56, 104},
case *syntax.InterfaceType:
typ := check.newInterface()
def.setUnderlying(typ)
- if def != nil {
- typ.obj = def.obj
- }
check.interfaceType(typ, e, def)
return typ
err := NewFunc(nopos, nil, "Error", sig)
// interface{ Error() string }
- ityp := &Interface{obj: obj, methods: []*Func{err}, complete: true}
+ ityp := &Interface{methods: []*Func{err}, complete: true}
computeInterfaceTypeSet(nil, nopos, ityp) // prevent races due to lazy computation of tset
typ.SetUnderlying(ityp)
typ := NewNamed(obj, nil, nil)
// interface{} // marked as comparable
- ityp := &Interface{obj: obj, complete: true, tset: &_TypeSet{nil, allTermlist, true}}
+ ityp := &Interface{complete: true, tset: &_TypeSet{nil, allTermlist, true}}
typ.SetUnderlying(ityp)
def(obj)
// An Interface represents an interface type.
type Interface struct {
check *Checker // for error reporting; nil once type set is computed
- 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
{Tuple{}, 12, 24},
{Signature{}, 28, 56},
{Union{}, 12, 24},
- {Interface{}, 44, 88},
+ {Interface{}, 40, 80},
{Map{}, 16, 32},
{Chan{}, 12, 24},
{Named{}, 56, 104},
case *ast.InterfaceType:
typ := check.newInterface()
def.setUnderlying(typ)
- if def != nil {
- typ.obj = def.obj
- }
check.interfaceType(typ, e, def)
return typ
err := NewFunc(token.NoPos, nil, "Error", sig)
// interface{ Error() string }
- ityp := &Interface{obj: obj, methods: []*Func{err}, complete: true}
+ ityp := &Interface{methods: []*Func{err}, complete: true}
computeInterfaceTypeSet(nil, token.NoPos, ityp) // prevent races due to lazy computation of tset
typ.SetUnderlying(ityp)
typ := NewNamed(obj, nil, nil)
// interface{} // marked as comparable
- ityp := &Interface{obj: obj, complete: true, tset: &_TypeSet{nil, allTermlist, true}}
+ ityp := &Interface{complete: true, tset: &_TypeSet{nil, allTermlist, true}}
typ.SetUnderlying(ityp)
def(obj)