aboutsummaryrefslogtreecommitdiff
path: root/src/go/types/typeparam.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/types/typeparam.go')
-rw-r--r--src/go/types/typeparam.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/go/types/typeparam.go b/src/go/types/typeparam.go
index 8cb44ea25e..33a516c209 100644
--- a/src/go/types/typeparam.go
+++ b/src/go/types/typeparam.go
@@ -74,23 +74,20 @@ func (t *TypeParam) Constraint() Type {
return t.bound
}
-// Bound returns the underlying type of the type parameter's
-// constraint.
-// Deprecated for external use. Use Constraint instead.
-func (t *TypeParam) Bound() *Interface {
- if iface, _ := under(t.Constraint()).(*Interface); iface != nil {
- return iface
+// SetConstraint sets the type constraint for t.
+func (t *TypeParam) SetConstraint(bound Type) {
+ if bound == nil {
+ panic("types2.TypeParam.SetConstraint: bound must not be nil")
}
- return &emptyInterface
+ t.bound = bound
}
-// TODO(rfindley): document the SetBound methods.
-
-func (t *TypeParam) SetBound(bound Type) {
- if bound == nil {
- panic("internal error: bound must not be nil")
+// iface returns the constraint interface of t.
+func (t *TypeParam) iface() *Interface {
+ if iface, _ := under(t.Constraint()).(*Interface); iface != nil {
+ return iface
}
- t.bound = bound
+ return &emptyInterface
}
func (t *TypeParam) Underlying() Type { return t }
@@ -135,5 +132,5 @@ func bindTParams(list []*TypeName) *TypeParams {
// Implementation
func (t *TypeParam) underIs(f func(Type) bool) bool {
- return t.Bound().typeSet().underIs(f)
+ return t.iface().typeSet().underIs(f)
}