Follow-up on comment in https://golang.org/cl/329309.
Change-Id: I31f746180237b916c1825fa1688641849478ba41
Reviewed-on: https://go-review.googlesource.com/c/go/+/332089
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
// Compute type set with a non-nil *Checker as soon as possible
// to report any errors. Subsequent uses of type sets should be
// using this computed type set and won't need to pass in a *Checker.
- check.later(func() { newTypeSet(check, iface.Pos(), ityp) })
+ check.later(func() { computeTypeSet(check, iface.Pos(), ityp) })
}
func flattenUnion(list []syntax.Expr, x syntax.Expr) []syntax.Expr {
}
// typeSet returns the type set for interface t.
-func (t *Interface) typeSet() *TypeSet { return newTypeSet(nil, nopos, t) }
+func (t *Interface) typeSet() *TypeSet { return computeTypeSet(nil, nopos, t) }
// is reports whether interface t represents types that all satisfy f.
func (t *Interface) is(f func(Type, bool) bool) bool {
pos = n.obj.pos
}
// TODO(gri) switch this to an unexported method on Checker.
- newTypeSet(t.check, pos, iface)
+ computeTypeSet(t.check, pos, iface)
return iface
}
// topTypeSet may be used as type set for the empty interface.
var topTypeSet TypeSet
-// newTypeSet may be called with check == nil.
-func newTypeSet(check *Checker, pos syntax.Pos, ityp *Interface) *TypeSet {
+// computeTypeSet may be called with check == nil.
+func computeTypeSet(check *Checker, pos syntax.Pos, ityp *Interface) *TypeSet {
if ityp.tset != nil {
return ityp.tset
}
var types Type
switch t := under(typ).(type) {
case *Interface:
- tset := newTypeSet(check, pos, t)
+ tset := computeTypeSet(check, pos, t)
for _, m := range tset.methods {
addMethod(pos, m, false) // use embedding position pos rather than m.pos
}
// interface methods. Delay this check to the end of type-checking.
check.later(func() {
if t := asInterface(typ); t != nil {
- tset := newTypeSet(check, pos, t) // TODO(gri) is this the correct position?
+ tset := computeTypeSet(check, pos, t) // TODO(gri) is this the correct position?
if tset.types != nil {
check.softErrorf(pos, "interface contains type constraints (%s)", tset.types)
return