@@ -96,9 +96,7 @@ class TyperState() {
9696 * its lower bound, top-level soft unions in the instance type are converted
9797 * to hard unions instead of being widened in `widenOr`.
9898 */
99- private var myHardVars : TypeVars = _
100- def hardVars : TypeVars = myHardVars
101- def hardVars_= (tvs : TypeVars ): Unit = myHardVars = tvs
99+ private var hardVars : TypeVars = _
102100
103101 private var upLevels : LevelMap = _
104102
@@ -112,7 +110,7 @@ class TyperState() {
112110 this .myConstraint = constraint
113111 this .previousConstraint = constraint
114112 this .myOwnedVars = SimpleIdentitySet .empty
115- this .myHardVars = SimpleIdentitySet .empty
113+ this .hardVars = SimpleIdentitySet .empty
116114 this .upLevels = SimpleIdentityMap .empty
117115 this .isCommitted = false
118116 this
@@ -131,6 +129,12 @@ class TyperState() {
131129 /** The uninstantiated variables */
132130 def uninstVars : collection.Seq [TypeVar ] = constraint.uninstVars
133131
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+
134138 /** The nestingLevel of `tv` in this typer state */
135139 def nestingLevel (tv : TypeVar ): Int =
136140 val own = upLevels(tv)
@@ -195,6 +199,7 @@ class TyperState() {
195199 if ! ownedVars.isEmpty then ownedVars.foreach(targetState.includeVar)
196200 else
197201 targetState.mergeConstraintWith(this )
202+ for tv <- hardVars do targetState.hardVars += tv
198203
199204 upLevels.foreachBinding { (tv, level) =>
200205 if level < targetState.nestingLevel(tv) then
@@ -250,7 +255,6 @@ class TyperState() {
250255 val otherLos = other.lower(p)
251256 val otherHis = other.upper(p)
252257 val otherEntry = other.entry(p)
253- if that.hardVars.contains(tv) then this .myHardVars += tv
254258 ( (otherLos eq constraint.lower(p)) || otherLos.forall(_ <:< p)) &&
255259 ( (otherHis eq constraint.upper(p)) || otherHis.forall(p <:< _)) &&
256260 ((otherEntry eq constraint.entry(p)) || otherEntry.match
0 commit comments