mirror of
https://github.com/golang/go
synced 2024-11-26 11:08:38 -07:00
go/types: rename IsMethodSet to IsConstraint (cleanup)
This is a port of CL 344872 to go/types. Change-Id: Id794f1fc3b86779ee32dbe5e656ffc747d44c3e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/346434 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>
This commit is contained in:
parent
b93581e47d
commit
ae2b2dc01a
@ -105,7 +105,7 @@ func (t *Interface) Empty() bool { return t.typeSet().IsAll() }
|
|||||||
func (t *Interface) IsComparable() bool { return t.typeSet().IsComparable() }
|
func (t *Interface) IsComparable() bool { return t.typeSet().IsComparable() }
|
||||||
|
|
||||||
// IsConstraint reports whether interface t is not just a method set.
|
// IsConstraint reports whether interface t is not just a method set.
|
||||||
func (t *Interface) IsConstraint() bool { return !t.typeSet().IsMethodSet() }
|
func (t *Interface) IsConstraint() bool { return t.typeSet().IsConstraint() }
|
||||||
|
|
||||||
// Complete computes the interface's type set. It must be called by users of
|
// Complete computes the interface's type set. It must be called by users of
|
||||||
// NewInterfaceType and NewInterface after the interface's embedded types are
|
// NewInterfaceType and NewInterface after the interface's embedded types are
|
||||||
|
@ -28,10 +28,8 @@ func (s *_TypeSet) IsEmpty() bool { return s.terms.isEmpty() }
|
|||||||
// IsAll reports whether type set s is the set of all types (corresponding to the empty interface).
|
// IsAll reports whether type set s is the set of all types (corresponding to the empty interface).
|
||||||
func (s *_TypeSet) IsAll() bool { return !s.comparable && len(s.methods) == 0 && s.terms.isAll() }
|
func (s *_TypeSet) IsAll() bool { return !s.comparable && len(s.methods) == 0 && s.terms.isAll() }
|
||||||
|
|
||||||
// TODO(gri) IsMethodSet is not a great name for this predicate. Find a better one.
|
// 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 type set s is described by a single set of methods.
|
|
||||||
func (s *_TypeSet) IsMethodSet() bool { return !s.comparable && s.terms.isAll() }
|
|
||||||
|
|
||||||
// IsComparable reports whether each type in the set is comparable.
|
// IsComparable reports whether each type in the set is comparable.
|
||||||
func (s *_TypeSet) IsComparable() bool {
|
func (s *_TypeSet) IsComparable() bool {
|
||||||
|
@ -149,7 +149,7 @@ func (check *Checker) ordinaryType(pos positioner, typ Type) {
|
|||||||
check.later(func() {
|
check.later(func() {
|
||||||
if t := asInterface(typ); t != nil {
|
if t := asInterface(typ); t != nil {
|
||||||
tset := computeInterfaceTypeSet(check, pos.Pos(), t) // TODO(gri) is this the correct position?
|
tset := computeInterfaceTypeSet(check, pos.Pos(), t) // TODO(gri) is this the correct position?
|
||||||
if !tset.IsMethodSet() {
|
if tset.IsConstraint() {
|
||||||
if tset.comparable {
|
if tset.comparable {
|
||||||
check.softErrorf(pos, _Todo, "interface is (or embeds) comparable")
|
check.softErrorf(pos, _Todo, "interface is (or embeds) comparable")
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user