@@ -96,9 +96,7 @@ class TyperState() {
96
96
* its lower bound, top-level soft unions in the instance type are converted
97
97
* to hard unions instead of being widened in `widenOr`.
98
98
*/
99
- private var myHardVars : TypeVars = _
100
- def hardVars : TypeVars = myHardVars
101
- def hardVars_= (tvs : TypeVars ): Unit = myHardVars = tvs
99
+ private var hardVars : TypeVars = _
102
100
103
101
private var upLevels : LevelMap = _
104
102
@@ -112,7 +110,7 @@ class TyperState() {
112
110
this .myConstraint = constraint
113
111
this .previousConstraint = constraint
114
112
this .myOwnedVars = SimpleIdentitySet .empty
115
- this .myHardVars = SimpleIdentitySet .empty
113
+ this .hardVars = SimpleIdentitySet .empty
116
114
this .upLevels = SimpleIdentityMap .empty
117
115
this .isCommitted = false
118
116
this
@@ -131,6 +129,12 @@ class TyperState() {
131
129
/** The uninstantiated variables */
132
130
def uninstVars : collection.Seq [TypeVar ] = constraint.uninstVars
133
131
132
+ /** Register type variable `tv` as hard. */
133
+ def hardenTypeVar (tv : TypeVar ): Unit = hardVars += tv
134
+
135
+ /** Is type variable `tv` registered as hard? */
136
+ def isHard (tv : TypeVar ): Boolean = hardVars.contains(tv)
137
+
134
138
/** The nestingLevel of `tv` in this typer state */
135
139
def nestingLevel (tv : TypeVar ): Int =
136
140
val own = upLevels(tv)
@@ -195,6 +199,7 @@ class TyperState() {
195
199
if ! ownedVars.isEmpty then ownedVars.foreach(targetState.includeVar)
196
200
else
197
201
targetState.mergeConstraintWith(this )
202
+ for tv <- hardVars do targetState.hardVars += tv
198
203
199
204
upLevels.foreachBinding { (tv, level) =>
200
205
if level < targetState.nestingLevel(tv) then
@@ -250,7 +255,6 @@ class TyperState() {
250
255
val otherLos = other.lower(p)
251
256
val otherHis = other.upper(p)
252
257
val otherEntry = other.entry(p)
253
- if that.hardVars.contains(tv) then this .myHardVars += tv
254
258
( (otherLos eq constraint.lower(p)) || otherLos.forall(_ <:< p)) &&
255
259
( (otherHis eq constraint.upper(p)) || otherHis.forall(p <:< _)) &&
256
260
((otherEntry eq constraint.entry(p)) || otherEntry.match
0 commit comments