name := w.p.info.Defs[decl.Name].(*types2.TypeName)
// Skip type declarations for interfaces that are only usable as
// type parameter bounds.
- if iface, ok := name.Type().Underlying().(*types2.Interface); ok && iface.IsConstraint() {
+ if iface, ok := name.Type().Underlying().(*types2.Interface); ok && !iface.IsMethodSet() {
break
}
check.expr(x, call.ArgList[0])
if x.mode != invalid {
if t := asInterface(T); t != nil {
- if t.IsConstraint() {
+ if !t.IsMethodSet() {
check.errorf(call, "cannot use interface %s in conversion (contains type list or is comparable)", T)
break
}
return false
}
u, _ := named.under().(*Interface)
- return u != nil && u.IsConstraint()
+ return u != nil && !u.IsMethodSet()
}
func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named) {
// IsComparable reports whether each type in interface t's type set is comparable.
func (t *Interface) IsComparable() bool { return t.typeSet().IsComparable() }
-// IsConstraint reports whether interface t is not just a method set.
-func (t *Interface) IsConstraint() bool { return t.typeSet().IsConstraint() }
+// IsMethodSet reports whether the interface t is fully described by its method set.
+func (t *Interface) IsMethodSet() bool { return t.typeSet().IsMethodSet() }
func (t *Interface) Underlying() Type { return t }
func (t *Interface) String() string { return TypeString(t, nil) }
return !s.comparable && len(s.methods) == 0 && s.terms.isAll()
}
-// IsConstraint reports whether type set s is not just a set of methods.
-func (s *_TypeSet) IsConstraint() bool { return s.comparable || !s.terms.isAll() }
+// IsMethodSet reports whether the interface t is fully described by its method set.
+func (s *_TypeSet) IsMethodSet() bool { return !s.comparable && s.terms.isAll() }
// IsComparable reports whether each type in the set is comparable.
func (s *_TypeSet) IsComparable() bool {
if t := asInterface(typ); t != nil {
pos := syntax.StartPos(e)
tset := computeInterfaceTypeSet(check, pos, t) // TODO(gri) is this the correct position?
- if tset.IsConstraint() {
+ if !tset.IsMethodSet() {
if tset.comparable {
check.softErrorf(pos, "interface is (or embeds) comparable")
} else {