Indicates whether a previous subtype check used GADT bounds
Indicates whether a previous subtype check used GADT bounds
Add constraint param <: bound
if fromBelow
is false, param >: bound
otherwise.
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 polytype pt
, possibly with type variables tvars
, to current constraint
and propagate all bounds.
Add polytype pt
, possibly with type variables tvars
, to current constraint
and propagate all bounds.
See Constraint#add
Form a normalized conjunction of two types.
Form a normalized conjunction of two types.
Note: For certain types, &
is distributed inside the type. This holds for
all types which are not value types (e.g. TypeBounds, ClassInfo,
ExprType, MethodType, PolyType). Also, when forming an &
,
instantiated TypeVars are dereferenced and annotations are stripped.
Finally, refined types with the same refined name are
opportunistically merged.
Sometimes, the conjunction of two types cannot be formed because the types are in conflict of each other. In particular:
In these cases, a MergeError is thrown.
Solve constraint set for given type parameter param
.
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 instantiating type
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.
Check that constraint is fully propagated. See comment in Config.checkConstraintsPropagated
Subtype test for the hk application tp1 = tycon1[args1]
.
Subtype test for the hk application tp1 = tycon1[args1]
.
Subtype test for the hk application tp2 = tycon2[args2]
.
Subtype test for the hk application tp2 = tycon2[args2]
.
We are currently comparing polytypes.
We are currently comparing polytypes. Used as a flag for
optimization: when false
, no need to do an expensive pruneLambdaParams
A new type comparer of the same type as this one, using the given context.
A new type comparer of the same type as this one, using the given context.
Perform op
in a mode where all attempts to set frozen
to true are ignored
Perform op
in a mode where all attempts to set frozen
to true are ignored
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.
The greatest lower bound of two types
The greatest lower bound of two types
The greatest lower bound of a list types
The greatest lower bound of a list types
Does type tp1
have a member with name name
whose normalized type is a subtype of
the normalized type of the refinement tp2
?
Normalization is as follows: If tp2
contains a skolem to its refinement type,
rebase both itself and the member info of tp
on a freshly created skolem type.
Does type tp1
have a member with name name
whose normalized type is a subtype of
the normalized type of the refinement tp2
?
Normalization is as follows: If tp2
contains a skolem to its refinement type,
rebase both itself and the member info of tp
on a freshly created skolem type.
The instance type of param
in the current constraint (which contains param
).
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.
Defer constraining type variables when compared against prototypes
Defer constraining type variables when compared against prototypes
Same as isSameType
but also can be applied to overloaded TermRefs, where
two overloaded refs are the same if they have pairwise equal alternatives
Same as isSameType
but also can be applied to overloaded TermRefs, where
two overloaded refs are the same if they have pairwise equal alternatives
Two types are the same if are mutual subtypes of each other
Two types are the same if are mutual subtypes of each other
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.
Subtype test for corresponding arguments in args1
, args2
according to
variances in type parameters tparams
.
Subtype test for corresponding arguments in args1
, args2
according to
variances in type parameters tparams
.
The least upper bound of two types
The least upper bound of two types
We do not admit singleton types in or-types as lubs.
The least upper bound of a list of types
The least upper bound of a list of types
A function implementing tp1
matches tp2
.
A function implementing tp1
matches tp2
.
Are syms1
and syms2
parameter lists with pairwise equivalent types?
Are syms1
and syms2
parameter lists with pairwise equivalent types?
Do generic types poly1
and poly2
have type parameters that
have the same bounds (after renaming one set to the other)?
Do generic types poly1
and poly2
have type parameters that
have the same bounds (after renaming one set to the other)?
Form a normalized conjunction of two types.
Form a normalized conjunction of two types.
Note: For certain types, |
is distributed inside the type. This holds for
all types which are not value types (e.g. TypeBounds, ClassInfo,
ExprType, MethodType, PolyType). Also, when forming an |
,
instantiated TypeVars are dereferenced and annotations are stripped.
Sometimes, the disjunction of two types cannot be formed because
the types are in conflict of each other. (@see andType
for an enumeration
of these cases). In cases of conflict a MergeError
is raised.
Apply erasure semantics. If erased is true, instead of creating an OrType, the lub will be computed using TypeCreator#erasedLub.
Record statistics about the total number of subtype checks and the number of "successful" subtype checks, i.e.
Record statistics about the total number of subtype checks and the number of "successful" subtype checks, i.e. checks that form part of a subtype derivation tree that's ultimately successful.
Show subtype goal that led to an assertion failure
Show subtype goal that led to an assertion failure
Constraint c1
subsumes constraint c2
, if under c2
as constraint we have
for all poly params p
defined in c2
as p >: L2 <: U2
:
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.
Is a subtype check in progress? In that case we may not permanently instantiate type variables, because the corresponding constraint might still be retracted and the instantiation should then be reversed.
Is a subtype check in progress? In that case we may not permanently instantiate type variables, because the corresponding constraint might still be retracted and the instantiation should then be reversed.
A hook for showing subtype traces.
A hook for showing subtype traces. Overridden in ExplainingTypeComparer
Instantiate param
to tp
if the constraint stays satisfiable
Instantiate param
to tp
if the constraint stays satisfiable
Throws an UnsupportedOperationException
with the given method name.
Throws an UnsupportedOperationException
with the given method name.
A type comparer that can record traces of subtype operations