1
0
mirror of https://github.com/golang/go synced 2024-09-30 01:34:35 -06:00

go/types: remove 1.18 APIs that have been replaced

Remove the Interface.IsConstraint, Signature.SetTypeParams, and
Signature.SetRecvTypeParams methods, as they have been replaced and
usage removed from x/tools.

Change-Id: I8786c3cf34e96ab5211cd8e7e6348e9ee792b843
Reviewed-on: https://go-review.googlesource.com/c/go/+/353570
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>
This commit is contained in:
Robert Findley 2021-10-01 14:22:34 -04:00
parent cc5e3de593
commit 9f8d558c3b
6 changed files with 6 additions and 17 deletions

View File

@ -112,7 +112,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
break break
} }
if t := asInterface(T); t != nil { if t := asInterface(T); t != nil {
if t.IsConstraint() { if !t.IsMethodSet() {
check.errorf(call, _Todo, "cannot use interface %s in conversion (contains type list or is comparable)", T) check.errorf(call, _Todo, "cannot use interface %s in conversion (contains type list or is comparable)", T)
break break
} }

View File

@ -586,7 +586,7 @@ func (check *Checker) isImportedConstraint(typ Type) bool {
return false return false
} }
u, _ := named.under().(*Interface) u, _ := named.under().(*Interface)
return u != nil && u.IsConstraint() return u != nil && !u.IsMethodSet()
} }
func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) { func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) {

View File

@ -106,12 +106,7 @@ func (t *Interface) IsComparable() bool { return t.typeSet().IsComparable() }
// IsMethodSet reports whether the interface t is fully described by its method // IsMethodSet reports whether the interface t is fully described by its method
// set. // set.
func (t *Interface) IsMethodSet() bool { return !t.typeSet().IsConstraint() } func (t *Interface) IsMethodSet() bool { return t.typeSet().IsMethodSet() }
// 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 // Complete computes the interface's type set. It must be called by users of
// NewInterfaceType and NewInterface after the interface's embedded types are // NewInterfaceType and NewInterface after the interface's embedded types are

View File

@ -82,15 +82,9 @@ func (s *Signature) Recv() *Var { return s.recv }
// TypeParams returns the type parameters of signature s, or nil. // TypeParams returns the type parameters of signature s, or nil.
func (s *Signature) TypeParams() *TypeParamList { return s.tparams } func (s *Signature) TypeParams() *TypeParamList { return s.tparams }
// SetTypeParams sets the type parameters of signature s.
func (s *Signature) SetTypeParams(tparams []*TypeParam) { s.tparams = bindTParams(tparams) }
// RecvTypeParams returns the receiver type parameters of signature s, or nil. // RecvTypeParams returns the receiver type parameters of signature s, or nil.
func (s *Signature) RecvTypeParams() *TypeParamList { return s.rparams } func (s *Signature) RecvTypeParams() *TypeParamList { return s.rparams }
// SetRecvTypeParams sets the receiver type params of signature s.
func (s *Signature) SetRecvTypeParams(rparams []*TypeParam) { s.rparams = bindTParams(rparams) }
// Params returns the parameters of signature s, or nil. // Params returns the parameters of signature s, or nil.
func (s *Signature) Params() *Tuple { return s.params } func (s *Signature) Params() *Tuple { return s.params }

View File

@ -28,8 +28,8 @@ func (s *_TypeSet) IsEmpty() bool { return s.terms.isEmpty() }
// IsAll reports whether type set s is the set of all types (corresponding to the empty interface). // IsAll reports whether type set s is the set of all types (corresponding to the empty interface).
func (s *_TypeSet) IsAll() bool { return !s.comparable && len(s.methods) == 0 && s.terms.isAll() } func (s *_TypeSet) IsAll() bool { return !s.comparable && len(s.methods) == 0 && s.terms.isAll() }
// IsConstraint reports whether type set s is not just a set of methods. // IsMethodSet reports whether the interface t is fully described by its method set.
func (s *_TypeSet) IsConstraint() bool { return s.comparable || !s.terms.isAll() } func (s *_TypeSet) IsMethodSet() bool { return !s.comparable && s.terms.isAll() }
// IsComparable reports whether each type in the set is comparable. // IsComparable reports whether each type in the set is comparable.
func (s *_TypeSet) IsComparable() bool { func (s *_TypeSet) IsComparable() bool {

View File

@ -139,7 +139,7 @@ func (check *Checker) varType(e ast.Expr) Type {
check.later(func() { check.later(func() {
if t := asInterface(typ); t != nil { if t := asInterface(typ); t != nil {
tset := computeInterfaceTypeSet(check, e.Pos(), t) // TODO(gri) is this the correct position? tset := computeInterfaceTypeSet(check, e.Pos(), t) // TODO(gri) is this the correct position?
if tset.IsConstraint() { if !tset.IsMethodSet() {
if tset.comparable { if tset.comparable {
check.softErrorf(e, _Todo, "interface is (or embeds) comparable") check.softErrorf(e, _Todo, "interface is (or embeds) comparable")
} else { } else {