aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/typeparam.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/types2/typeparam.go')
-rw-r--r--src/cmd/compile/internal/types2/typeparam.go27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/types2/typeparam.go b/src/cmd/compile/internal/types2/typeparam.go
index 2614f467b1..27e6e35588 100644
--- a/src/cmd/compile/internal/types2/typeparam.go
+++ b/src/cmd/compile/internal/types2/typeparam.go
@@ -67,7 +67,7 @@ func (t *TypeParam) Constraint() Type {
if n, _ := t.bound.(*Named); n != nil {
pos = n.obj.pos
}
- computeTypeSet(t.check, pos, iface)
+ computeInterfaceTypeSet(t.check, pos, iface)
}
return t.bound
}
@@ -80,14 +80,6 @@ func (t *TypeParam) SetConstraint(bound Type) {
t.bound = bound
}
-// iface returns the constraint interface of t.
-func (t *TypeParam) iface() *Interface {
- if iface, _ := under(t.Constraint()).(*Interface); iface != nil {
- return iface
- }
- return &emptyInterface
-}
-
// Bound returns the constraint interface of t.
// Deprecated. Only here for the compiler.
// TODO(gri) remove in favor of uses of Constraint.
@@ -136,6 +128,23 @@ func bindTParams(list []*TypeName) *TypeParams {
// ----------------------------------------------------------------------------
// Implementation
+// iface returns the constraint interface of t.
+func (t *TypeParam) iface() *Interface {
+ if iface, _ := under(t.Constraint()).(*Interface); iface != nil {
+ return iface
+ }
+ return &emptyInterface
+}
+
+// structuralType returns the structural type of the type parameter's constraint; or nil.
+func (t *TypeParam) structuralType() Type {
+ return t.iface().typeSet().structuralType()
+}
+
+func (t *TypeParam) is(f func(*term) bool) bool {
+ return t.iface().typeSet().is(f)
+}
+
func (t *TypeParam) underIs(f func(Type) bool) bool {
return t.iface().typeSet().underIs(f)
}