@@ -25,20 +25,19 @@ object TyperState {
2525
2626 type LevelMap = SimpleIdentityMap [TypeVar , Integer ]
2727
28- opaque type Snapshot = (Constraint , TypeVars , TypeVars , LevelMap )
28+ opaque type Snapshot = (Constraint , TypeVars , LevelMap )
2929
3030 extension (ts : TyperState )
3131 def snapshot ()(using Context ): Snapshot =
32- (ts.constraint, ts.ownedVars, ts.hardVars, ts. upLevels)
32+ (ts.constraint, ts.ownedVars, ts.upLevels)
3333
3434 def resetTo (state : Snapshot )(using Context ): Unit =
35- val (constraint, ownedVars, hardVars, upLevels) = state
35+ val (constraint, ownedVars, upLevels) = state
3636 for tv <- ownedVars do
3737 if ! ts.ownedVars.contains(tv) then // tv has been instantiated
3838 tv.resetInst(ts)
3939 ts.constraint = constraint
4040 ts.ownedVars = ownedVars
41- ts.hardVars = hardVars
4241 ts.upLevels = upLevels
4342}
4443
@@ -92,12 +91,6 @@ class TyperState() {
9291 def ownedVars : TypeVars = myOwnedVars
9392 def ownedVars_= (vs : TypeVars ): Unit = myOwnedVars = vs
9493
95- /** The set of type variables `tv` such that, if `tv` is instantiated to
96- * its lower bound, top-level soft unions in the instance type are converted
97- * to hard unions instead of being widened in `widenOr`.
98- */
99- private var hardVars : TypeVars = _
100-
10194 private var upLevels : LevelMap = _
10295
10396 /** Initializes all fields except reporter, isCommittable, which need to be
@@ -110,7 +103,6 @@ class TyperState() {
110103 this .myConstraint = constraint
111104 this .previousConstraint = constraint
112105 this .myOwnedVars = SimpleIdentitySet .empty
113- this .hardVars = SimpleIdentitySet .empty
114106 this .upLevels = SimpleIdentityMap .empty
115107 this .isCommitted = false
116108 this
@@ -122,19 +114,12 @@ class TyperState() {
122114 val ts = TyperState ().init(this , this .constraint)
123115 .setReporter(reporter)
124116 .setCommittable(committable)
125- ts.hardVars = this .hardVars
126117 ts.upLevels = upLevels
127118 ts
128119
129120 /** The uninstantiated variables */
130121 def uninstVars : collection.Seq [TypeVar ] = constraint.uninstVars
131122
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-
138123 /** The nestingLevel of `tv` in this typer state */
139124 def nestingLevel (tv : TypeVar ): Int =
140125 val own = upLevels(tv)
@@ -195,11 +180,9 @@ class TyperState() {
195180 constr.println(i " committing $this to $targetState, fromConstr = $constraint, toConstr = ${targetState.constraint}" )
196181 if targetState.constraint eq previousConstraint then
197182 targetState.constraint = constraint
198- targetState.hardVars = hardVars
199183 if ! ownedVars.isEmpty then ownedVars.foreach(targetState.includeVar)
200184 else
201185 targetState.mergeConstraintWith(this )
202- for tv <- hardVars do targetState.hardVars += tv
203186
204187 upLevels.foreachBinding { (tv, level) =>
205188 if level < targetState.nestingLevel(tv) then
@@ -247,7 +230,9 @@ class TyperState() {
247230 val tvars = tl.paramRefs.map(other.typeVarOfParam(_)).collect { case tv : TypeVar => tv }
248231 if this .isCommittable then
249232 tvars.foreach(tvar =>
250- if ! tvar.inst.exists && ! isOwnedAnywhere(this , tvar) then includeVar(tvar))
233+ if ! tvar.inst.exists then
234+ if ! isOwnedAnywhere(this , tvar) then includeVar(tvar)
235+ if constraint.isHard(tvar) then constraint = constraint.withHard(tvar))
251236 typeComparer.addToConstraint(tl, tvars)
252237 }) &&
253238 // Integrate the additional constraints on type variables from `other`
0 commit comments