aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/typeparam.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-07-28 16:58:57 -0700
committerRobert Griesemer <gri@golang.org>2021-07-29 21:05:49 +0000
commit5ecbd811b54f478244b7e54a621f32b5b8e3ea95 (patch)
treee6956a23dd26c301bf7660634118b865d760eaec /src/cmd/compile/internal/types2/typeparam.go
parent46cc68638143770206e0894add7021990a9bec52 (diff)
downloadgo-5ecbd811b54f478244b7e54a621f32b5b8e3ea95.tar.gz
go-5ecbd811b54f478244b7e54a621f32b5b8e3ea95.zip
[dev.typeparams] cmd/compile/internal/types2: (TypeParam) SetBound -> SetConstraint
This matches the accessor named Constraint, and any documentation we have so far. Use iface instead of Bound internally to types2; keep Bound because of two external uses but mark it as deprecated. Adjust clients. Change-Id: Id1a2c2f28259a16082e875eee0534d46cf157336 Reviewed-on: https://go-review.googlesource.com/c/go/+/338196 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/typeparam.go')
-rw-r--r--src/cmd/compile/internal/types2/typeparam.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/cmd/compile/internal/types2/typeparam.go b/src/cmd/compile/internal/types2/typeparam.go
index aff03a5f04..9f8c921bf1 100644
--- a/src/cmd/compile/internal/types2/typeparam.go
+++ b/src/cmd/compile/internal/types2/typeparam.go
@@ -72,21 +72,27 @@ 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 {
+// 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")
+ }
+ 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
}
-func (t *TypeParam) SetBound(bound Type) {
- if bound == nil {
- panic("types2.TypeParam.SetBound: bound must not be nil")
- }
- t.bound = bound
+// Bound returns the constraint interface of t.
+// Deprecated. Only here for the compiler.
+// TODO(gri) remove in favor of uses of Constraint.
+func (t *TypeParam) Bound() *Interface {
+ return t.iface()
}
func (t *TypeParam) Underlying() Type { return t }
@@ -132,5 +138,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)
}