Constraint

abstract class Constraint extends Showable

Constraint over undetermined type parameters. Constraints are built over values of the following types:

  • TypeLambda A constraint constrains the type parameters of a set of TypeLambdas
  • TypeParamRef The parameters of the constrained type lambdas
  • TypeVar Every constrained parameter might be associated with a TypeVar that has the TypeParamRef as origin.
trait Showable
class Object
trait Matchable
class Any

Type members

Types

type This <: Constraint

Value members

Abstract methods

def &(other: Constraint, otherHasErrors: Boolean)(using Context): Constraint

The weakest constraint that subsumes both this constraint and other. The constraints should be compatible, meaning that a type lambda occurring in both constraints is associated with the same typevars in each.

The weakest constraint that subsumes both this constraint and other. The constraints should be compatible, meaning that a type lambda occurring in both constraints is associated with the same typevars in each.

Value Params
otherHasErrors

If true, handle incompatible constraints by returning an approximate constraint, instead of failing with an exception

def add(poly: TypeLambda, tvars: List[TypeVar])(using Context): This

A new constraint which is derived from this constraint by adding entries for all type parameters of poly.

A new constraint which is derived from this constraint by adding entries for all type parameters of poly.

Value Params
tvars

A list of type variables associated with the params, or Nil if the constraint will just be checked for satisfiability but will solved to give instances of type variables.

A constraint that includes the relationship p1 <: p2. <: relationships between parameters ("edges") are propagated, but non-parameter bounds are left alone.

A constraint that includes the relationship p1 <: p2. <: relationships between parameters ("edges") are propagated, but non-parameter bounds are left alone.

def checkClosed(using Context): Unit

Check that constraint only refers to TypeParamRefs bound by itself

Check that constraint only refers to TypeParamRefs bound by itself

Check that every typevar om this constraint has as origin a type parameter of athe type lambda that is associated with the typevar itself.

Check that every typevar om this constraint has as origin a type parameter of athe type lambda that is associated with the typevar itself.

Check that no constrained parameter contains itself as a bound

Check that no constrained parameter contains itself as a bound

Does the constraint's domain contain the type parameters of tl?

Does the constraint's domain contain the type parameters of tl?

Does the constraint's domain contain the type parameter param?

Does the constraint's domain contain the type parameter param?

def contains(tvar: TypeVar): Boolean

Does this constraint contain the type variable tvar and is it uninstantiated?

Does this constraint contain the type variable tvar and is it uninstantiated?

A string describing the constraint's contents without a header or trailer

A string describing the constraint's contents without a header or trailer

The type lambdas constrained by this constraint

The type lambdas constrained by this constraint

The type lambda parameters constrained by this constraint

The type lambda parameters constrained by this constraint

The given tl in case it is not contained in this constraint, a fresh copy of tl otherwise.

The given tl in case it is not contained in this constraint, a fresh copy of tl otherwise.

def entry(param: TypeParamRef): Type

The constraint entry for given type parameter param, or NoType if param is not part of the constraint domain. Note: Low level, implementation dependent.

The constraint entry for given type parameter param, or NoType if param is not part of the constraint domain. Note: Low level, implementation dependent.

lower(param) \ lower(butNot)

lower(param) \ lower(butNot)

upper(param) \ upper(butNot)

upper(param) \ upper(butNot)

Check whether predicate holds for all parameters in constraint

Check whether predicate holds for all parameters in constraint

Perform operation op on all typevars that do not have their inst field set.

Perform operation op on all typevars that do not have their inst field set.

def instType(tvar: TypeVar): Type

Gives for each instantiated type var that does not yet have its inst field set, the instance value stored in the constraint. Storing instances in constraints is done only in a temporary way for contexts that may be retracted without also retracting the type var as a whole.

Gives for each instantiated type var that does not yet have its inst field set, the instance value stored in the constraint. Storing instances in constraints is done only in a temporary way for contexts that may be retracted without also retracting the type var as a whole.

def isLess(param1: TypeParamRef, param2: TypeParamRef): Boolean

Is it known that param1 <:< param2?

Is it known that param1 <:< param2?

Is entry associated with tl removable? This is the case if all type parameters of the entry are associated with type variables which have their inst fields set.

Is entry associated with tl removable? This is the case if all type parameters of the entry are associated with type variables which have their inst fields set.

The parameters that are known to be smaller wrt <: than param

The parameters that are known to be smaller wrt <: than param

The lower dominator set.

The lower dominator set.

This is like lower, except that each parameter returned is no smaller than every other returned parameter.

The upper dominator set.

The upper dominator set.

This is like upper, except that each parameter returned is no greater than every other returned parameter.

The constraint bounds for given type parameter param. Poly params that are known to be smaller or greater than param are not contained in the return bounds.

The constraint bounds for given type parameter param. Poly params that are known to be smaller or greater than param are not contained in the return bounds.

Does param occur at the toplevel in tp ? Toplevel means: the type itself or a factor in some combination of & or | types.

Does param occur at the toplevel in tp ? Toplevel means: the type itself or a factor in some combination of & or | types.

def remove(tl: TypeLambda)(using Context): This

A new constraint with all entries coming from tl removed.

A new constraint with all entries coming from tl removed.

def replace(param: TypeParamRef, tp: Type)(using Context): This

A new constraint which is derived from this constraint by removing the type parameter param from the domain and replacing all top-level occurrences of the parameter elsewhere in the constraint by type tp, or a conservative approximation of it if that is needed to avoid cycles. Occurrences nested inside a refinement or prefix are not affected.

A new constraint which is derived from this constraint by removing the type parameter param from the domain and replacing all top-level occurrences of the parameter elsewhere in the constraint by type tp, or a conservative approximation of it if that is needed to avoid cycles. Occurrences nested inside a refinement or prefix are not affected.

def subst(from: TypeLambda, to: TypeLambda)(using Context): This

A new constraint with entry from replaced with to Rerences to from from within other constraint bounds are updated to to. Type variables are left alone.

A new constraint with entry from replaced with to Rerences to from from within other constraint bounds are updated to to. Type variables are left alone.

The type variable corresponding to parameter param, or NoType, if param is not in constrained or is not paired with a type variable.

The type variable corresponding to parameter param, or NoType, if param is not in constrained or is not paired with a type variable.

def unify(p1: TypeParamRef, p2: TypeParamRef)(using Context): This

A constraint resulting from adding p2 = p1 to this constraint, and at the same time transferring all bounds of p2 to p1

A constraint resulting from adding p2 = p1 to this constraint, and at the same time transferring all bounds of p2 to p1

The uninstantiated typevars of this constraint, which still have a bounds constraint

The uninstantiated typevars of this constraint, which still have a bounds constraint

def updateEntry(param: TypeParamRef, tp: Type)(using Context): This

A new constraint which is derived from this constraint by updating the entry for parameter param to tp. tp can be one of the following:

A new constraint which is derived from this constraint by updating the entry for parameter param to tp. tp can be one of the following:

  • A TypeBounds value, indicating new constraint bounds
  • Another type, indicating a solution for the parameter

The parameters that are known to be greater wrt <: than param

The parameters that are known to be greater wrt <: than param

Inherited methods

def fallbackToText(printer: Printer): Text

A fallback text representation, if the pattern matching in Printers does not have a case for this showable element

A fallback text representation, if the pattern matching in Printers does not have a case for this showable element

Inherited from
Showable
def show(using Context): String

The string representation of this showable element.

The string representation of this showable element.

Inherited from
Showable
def showIndented(margin: Int)(using Context): String

The string representation with each line after the first one indented by the given given margin (in spaces).

The string representation with each line after the first one indented by the given given margin (in spaces).

Inherited from
Showable
def showSummary(depth: Int)(using Context): String

The summarized string representation of this showable element. Recursion depth is limited to some smallish value. Default is Config.summarizeDepth.

The summarized string representation of this showable element. Recursion depth is limited to some smallish value. Default is Config.summarizeDepth.

Inherited from
Showable
def toText(printer: Printer): Text

The text representation of this showable element. This normally dispatches to a pattern matching method in Printers.

The text representation of this showable element. This normally dispatches to a pattern matching method in Printers.

Inherited from
Showable