Methods for adding constraints and solving them.
What goes into a Constraint as opposed to a ConstrainHandler?
Constraint code is purely functional: Operations get constraints and produce new ones. Constraint code does not have access to a type-comparer. Anything regarding lubs and glbs has to be done elsewhere.
By comparison: Constraint handlers are parts of type comparers and can use their functionality. Constraint handlers update the current constraint as a side effect.
Constructors
Members
We are currently comparing type lambdas. Used as a flag for
optimization: when false
, no need to do an expensive pruneLambdaParams
We are currently comparing type lambdas. Used as a flag for
optimization: when false
, no need to do an expensive pruneLambdaParams
If the constraint is frozen we cannot add new bounds to the constraint.
If the constraint is frozen we cannot add new bounds to the constraint.
If set, align arguments S1
, S2
when taking the glb
T1 { X = S1 } & T2 { X = S2 }
of a constraint upper bound for some type parameter.
Aligning means comp...
If set, align arguments S1
, S2
when taking the glb
T1 { X = S1 } & T2 { X = S2 }
of a constraint upper bound for some type parameter.
Aligning means computing S1 =:= S2
which may change the current constraint.
See note in TypeComparer#distributeAnd.
Add constraint param <: bound
if fromBelow
is false, param >: bound
otherwise.
bound
is assumed to be in normalized form, as specified in firstTry
and
s...
Add constraint param <: bound
if fromBelow
is false, param >: bound
otherwise.
bound
is assumed to be in normalized form, as specified in firstTry
and
secondTry
of TypeComparer
. In particular, it should not be an alias type,
lazy ref, typevar, wildcard type, error type. In addition, upper bounds may
not be AndTypes and lower bounds may not be OrTypes. This is assured by the
way isSubType is organized.
Add type lambda tl
, possibly with type variables tvars
, to current constraint
and propagate all bounds.
Add type lambda tl
, possibly with type variables tvars
, to current constraint
and propagate all bounds.
Solve constraint set for given type parameter param
.
If fromBelow
is true the parameter is approximated by its lower bound,
otherwise it is approximated...
Solve constraint set for given type parameter param
.
If fromBelow
is true the parameter is approximated by its lower bound,
otherwise it is approximated by its upper bound. However, any occurrences
of the parameter in a refinement somewhere in the bound are removed. Also
wildcard types in bounds are approximated by their upper or lower bounds.
(Such occurrences can arise for F-bounded types).
The constraint is left unchanged.
The current bounds of type parameter param
The current bounds of type parameter param
Can param
be constrained with new bounds?
Can param
be constrained with new bounds?
Check that constraint is fully propagated. See comment in Config.checkConstraintsPropagated
Check that constraint is fully propagated. See comment in Config.checkConstraintsPropagated
We are currently comparing type lambdas. Used as a flag for
optimization: when false
, no need to do an expensive pruneLambdaParams
We are currently comparing type lambdas. Used as a flag for
optimization: when false
, no need to do an expensive pruneLambdaParams
If the constraint is frozen we cannot add new bounds to the constraint.
If the constraint is frozen we cannot add new bounds to the constraint.
If set, align arguments S1
, S2
when taking the glb
T1 { X = S1 } & T2 { X = S2 }
of a constraint upper bound for some type parameter.
Aligning means comp...
If set, align arguments S1
, S2
when taking the glb
T1 { X = S1 } & T2 { X = S2 }
of a constraint upper bound for some type parameter.
Aligning means computing S1 =:= S2
which may change the current constraint.
See note in TypeComparer#distributeAnd.
The instance type of param
in the current constraint (which contains param
).
If fromBelow
is true, the instance type is the lub of the parameter's
lower...
The instance type of param
in the current constraint (which contains param
).
If fromBelow
is true, the instance type is the lub of the parameter's
lower bounds; otherwise it is the glb of its upper bounds. However,
a lower bound instantiation can be a singleton type only if the upper bound
is also a singleton type.
Test whether the lower bounds of all parameters in this constraint are a solution to the constraint.
Test whether the lower bounds of all parameters in this constraint are a solution to the constraint.
Narrow one of the bounds of type parameter param
If isUpper
is true, ensure that param <:
bound, otherwise ensure that
param >: bound`.
Narrow one of the bounds of type parameter param
If isUpper
is true, ensure that param <:
bound, otherwise ensure that
param >: bound`.
Constraint c1
subsumes constraint c2
, if under c2
as constraint we have
for all poly params p
defined in c2
as p >: L2 <: U2
:
c1 defines p with bounds p...
Constraint c1
subsumes constraint c2
, if under c2
as constraint we have
for all poly params p
defined in c2
as p >: L2 <: U2
:
c1 defines p with bounds p >: L1 <: U1, and L2 <: L1, and U1 <: U2
Both c1
and c2
are required to derive from constraint pre
, possibly
narrowing it with further bounds.
Instantiate param
to tp
if the constraint stays satisfiable
Instantiate param
to tp
if the constraint stays satisfiable
Make p2 = p1, transfer all bounds of p2 to p1
Make p2 = p1, transfer all bounds of p2 to p1