Skip to content

Commit 08ac0a0

Browse files
committed
Move TyperState.instType
1 parent 225aabc commit 08ac0a0

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ trait ConstraintHandling {
5050
*/
5151
protected var comparedTypeLambdas: Set[TypeLambda] = Set.empty
5252

53+
/** Gives for each instantiated type var that does not yet have its `inst` field
54+
* set, the instance value stored in the constraint. Storing instances in constraints
55+
* is done only in a temporary way for contexts that may be retracted
56+
* without also retracting the type var as a whole.
57+
*/
58+
def instType(tvar: TypeVar): Type = constraint.entry(tvar.origin) match {
59+
case _: TypeBounds => NoType
60+
case tp: TypeParamRef =>
61+
var tvar1 = constraint.typeVarOfParam(tp)
62+
if (tvar1.exists) tvar1 else tp
63+
case tp => tp
64+
}
65+
5366
protected def addOneBound(param: TypeParamRef, bound: Type, isUpper: Boolean): Boolean =
5467
!constraint.contains(param) || {
5568
def occursIn(bound: Type): Boolean = {

compiler/src/dotty/tools/dotc/core/TyperState.scala

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,6 @@ class TyperState(previous: TyperState /* | Null */) {
7979
def ownedVars: TypeVars = myOwnedVars
8080
def ownedVars_=(vs: TypeVars): Unit = myOwnedVars = vs
8181

82-
/** Gives for each instantiated type var that does not yet have its `inst` field
83-
* set, the instance value stored in the constraint. Storing instances in constraints
84-
* is done only in a temporary way for contexts that may be retracted
85-
* without also retracting the type var as a whole.
86-
*/
87-
def instType(tvar: TypeVar)(implicit ctx: Context): Type = constraint.entry(tvar.origin) match {
88-
case _: TypeBounds => NoType
89-
case tp: TypeParamRef =>
90-
var tvar1 = constraint.typeVarOfParam(tp)
91-
if (tvar1.exists) tvar1 else tp
92-
case tp => tp
93-
}
94-
9582
/** The closest ancestor of this typer state (including possibly this typer state itself)
9683
* which is not yet committed, or which does not have a parent.
9784
*/
@@ -173,7 +160,7 @@ class TyperState(previous: TyperState /* | Null */) {
173160
val toCollect = new mutable.ListBuffer[TypeLambda]
174161
constraint foreachTypeVar { tvar =>
175162
if (!tvar.inst.exists) {
176-
val inst = instType(tvar)
163+
val inst = ctx.typeComparer.instType(tvar)
177164
if (inst.exists && (tvar.owningState.get eq this)) {
178165
tvar.inst = inst
179166
val lam = tvar.origin.binder

0 commit comments

Comments
 (0)