OrderingConstraint

dotty.tools.dotc.core.OrderingConstraint
See theOrderingConstraint companion object
class OrderingConstraint(boundsMap: ParamBounds, lowerMap: ParamOrdering, upperMap: ParamOrdering, hardVars: TypeVars) extends Constraint

Constraint over undetermined type parameters that keeps separate maps to reflect parameter orderings.

Value parameters

boundsMap

a map from TypeLambda to arrays. Each array contains twice the number of entries as there a type parameters in the TypeLambda. The first half of the array contains the type bounds that constrain the lambda's type parameters. The second half might contain type variables that track the corresponding parameters, or is left empty (filled with nulls). An instantiated type parameter is represented by having its instance type in the corresponding array entry. The dual use of arrays for poly params and typevars is to save space and hopefully gain some speed.

hardVars

a set of type variables that are marked as hard and therefore will not undergo a widenUnion when instantiated to their lower bound.

lowerMap

a map from TypeLambdas to arrays. Each array entry corresponds to a parameter P of the type lambda; it contains all constrained parameters Q that are known to be smaller than P, i.e. Q <: P.

upperMap

a map from TypeLambdas to arrays. Each array entry corresponds to a parameter P of the type lambda; it contains all constrained parameters Q that are known to be greater than P, i.e. P <: Q.

Attributes

Companion
object
Graph
Supertypes
class Constraint
trait Showable
class Object
trait Matchable
class Any
Self type

Members list

Type members

Types

Value members

Concrete methods

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 parameters

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.

Attributes

def addLess(param1: TypeParamRef, param2: TypeParamRef, direction: UnificationDirection)(using Context): This

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.

Value parameters

direction

Must be set to KeepParam1 or KeepParam2 when p2 <: p1 is already true depending on which parameter the caller intends to keep. This will avoid propagating bounds that will be redundant after p1 and p2 are unified.

Attributes

def adjustDeps(entry: Type | Null, prevEntry: Type | Null, srcParam: TypeParamRef, ignoreBinding: TypeParamRef | Null)(using Context): this.type

Adjust dependencies to account for the delta of previous entry prevEntry and the new bound entry for the type parameter srcParam.

Adjust dependencies to account for the delta of previous entry prevEntry and the new bound entry for the type parameter srcParam.

Attributes

def adjustDeps(poly: TypeLambda, entries: Array[Type], add: Boolean)(using Context): this.type

Adjust dependencies to account for adding or dropping all entries associated with poly.

Adjust dependencies to account for adding or dropping all entries associated with poly.

Value parameters

add

if true, entries is added, otherwise it is dropped

Attributes

def bounds(param: TypeParamRef)(using Context): TypeBounds

The current bounds of type parameter param

The current bounds of type parameter param

Attributes

override 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

Attributes

Definition Classes

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.

Attributes

def checkWellFormed()(using Context): this.type

Depending on Config settngs:

Depending on Config settngs:

  • Under checkConstraintsNonCyclic, check that no constrained parameter contains itself as a bound.
  • Under checkConstraintDeps, check hat reverse dependencies in constraints are correct and complete.

Attributes

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

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

Attributes

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

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

Attributes

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?

Attributes

override def dependsOn(tv: TypeVar, except: TypeVars, co: Boolean)(using Context): Boolean

Does the constraint restricted to variables outside except depend on tv in the given direction co?

Does the constraint restricted to variables outside except depend on tv in the given direction co?

Value parameters

`co`

If true, test whether the constraint would change if the variable is made larger otherwise, test whether the constraint would change if the variable is made smaller.

Attributes

Definition Classes

A string representing the two dependency maps

A string representing the two dependency maps

Attributes

The type lambdas constrained by this constraint

The type lambdas constrained by this constraint

Attributes

The type lambda parameters constrained by this constraint

The type lambda parameters constrained by this constraint

Attributes

def dropDeps(param: TypeParamRef)(using Context): Unit

Remove all reverse dependencies of param

Remove all reverse dependencies of param

Attributes

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.

Attributes

def entry(param: TypeParamRef): Type

The boundsMap entry corresponding to param

The boundsMap entry corresponding to param

Attributes

lower(param) \ lower(butNot)

lower(param) \ lower(butNot)

Attributes

upper(param) \ upper(butNot)

upper(param) \ upper(butNot)

Attributes

Check whether predicate holds for all parameters in constraint

Check whether predicate holds for all parameters in constraint

Attributes

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.

Attributes

Mark toplevel type vars in tp as hard.

Mark toplevel type vars in tp as hard.

Attributes

Whether tl is present in both this and that but is associated with different TypeVars there, meaning that the constraints cannot be merged.

Whether tl is present in both this and that but is associated with different TypeVars there, meaning that the constraints cannot be merged.

Attributes

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.

Attributes

def isHard(tv: TypeVar): Boolean

Is tv marked as hard in the constraint?

Is tv marked as hard in the constraint?

Attributes

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

Is it known that param1 <:< param2?

Is it known that param1 <:< param2?

Attributes

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.

Attributes

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

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

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

def occursAtToplevel(param: TypeParamRef, inst: Type)(using Context): Boolean

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.

Attributes

def order(current: This, param1: TypeParamRef, param2: TypeParamRef, direction: UnificationDirection)(using Context): This

Add the fact param1 <: param2 to the constraint current and propagate <:< relationships between parameters ("edges") but not bounds.

Add the fact param1 <: param2 to the constraint current and propagate <:< relationships between parameters ("edges") but not bounds.

Attributes

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

A new constraint with all entries coming from tl removed.

A new constraint with all entries coming from tl removed.

Attributes

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.

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.

Attributes

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.

Attributes

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
override 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.

Attributes

Definition Classes

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.

Attributes

The uninstantiated typevars of this constraint

The uninstantiated typevars of this constraint

Attributes

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

Attributes

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

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

Attributes

def validBoundFor(param: TypeParamRef, bound: Type, isUpper: Boolean)(using Context): Type

Sanitize bound to make it either a valid upper or lower bound for param depending on isUpper.

Sanitize bound to make it either a valid upper or lower bound for param depending on isUpper.

Toplevel references to param, are replaced by Any if isUpper is true and Nothing otherwise.

Attributes

See also

occursAtTopLevel for a definition of "toplevel"

validBoundsFor to sanitize both the lower and upper bound at once.

def validBoundsFor(param: TypeParamRef, bounds: TypeBounds)(using Context): Type

Sanitize bounds to make them valid constraints for param.

Sanitize bounds to make them valid constraints for param.

Attributes

See also

validBoundFor for details.

def withHard(tv: TypeVar)(using Context): This

The same as this constraint, but with tv marked as hard.

The same as this constraint, but with tv marked as hard.

Attributes

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

Attributes

Inherited from:
Showable
def show(using Context): String

The string representation of this showable element.

The string representation of this showable element.

Attributes

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).

Attributes

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.

Attributes

Inherited from:
Showable

Extensions

Extensions

extension (deps: SimpleIdentityMap[TypeParamRef, SimpleIdentitySet[TypeParamRef]])

Null-safe indexing

Null-safe indexing

Attributes