]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types: add the Interface.IsMethodSet method
authorRobert Findley <rfindley@google.com>
Mon, 27 Sep 2021 23:49:38 +0000 (19:49 -0400)
committerRobert Findley <rfindley@google.com>
Tue, 28 Sep 2021 15:20:55 +0000 (15:20 +0000)
As pointed out in #47916, the IsConstraint method becomes ambiguously
named if ever we allow interfaces with structural restrictions outside
of constraint position.

Add instead an IsMethodSet method, which has the opposite sense and
avoids this ambiguity. In a subsequent CL the IsConstraint method will
be removed, once x/tools has been updated to use the IsMethodSet API.

Updates #47916

Change-Id: I82ad16b111464b0cd2f354b8ecdd4b3f14796cd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/352616
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/interface.go

index c67aca7a2012427203fbeb7a566031587f5d80c4..ccea1f6dccf2a5a8318fd1493144159ba526f3cd 100644 (file)
@@ -104,7 +104,13 @@ func (t *Interface) Empty() bool { return t.typeSet().IsAll() }
 // IsComparable reports whether each type in interface t's type set is comparable.
 func (t *Interface) IsComparable() bool { return t.typeSet().IsComparable() }
 
+// IsMethodSet reports whether the interface t is fully described by its method
+// set.
+func (t *Interface) IsMethodSet() bool { return !t.typeSet().IsConstraint() }
+
 // IsConstraint reports whether interface t is not just a method set.
+//
+// TODO(rfindley): remove this method.
 func (t *Interface) IsConstraint() bool { return t.typeSet().IsConstraint() }
 
 // Complete computes the interface's type set. It must be called by users of