@@ -25,20 +25,19 @@ object TyperState {
25
25
26
26
type LevelMap = SimpleIdentityMap [TypeVar , Integer ]
27
27
28
- opaque type Snapshot = (Constraint , TypeVars , TypeVars , LevelMap )
28
+ opaque type Snapshot = (Constraint , TypeVars , LevelMap )
29
29
30
30
extension (ts : TyperState )
31
31
def snapshot ()(using Context ): Snapshot =
32
- (ts.constraint, ts.ownedVars, ts.hardVars, ts. upLevels)
32
+ (ts.constraint, ts.ownedVars, ts.upLevels)
33
33
34
34
def resetTo (state : Snapshot )(using Context ): Unit =
35
- val (constraint, ownedVars, hardVars, upLevels) = state
35
+ val (constraint, ownedVars, upLevels) = state
36
36
for tv <- ownedVars do
37
37
if ! ts.ownedVars.contains(tv) then // tv has been instantiated
38
38
tv.resetInst(ts)
39
39
ts.constraint = constraint
40
40
ts.ownedVars = ownedVars
41
- ts.hardVars = hardVars
42
41
ts.upLevels = upLevels
43
42
}
44
43
@@ -92,12 +91,6 @@ class TyperState() {
92
91
def ownedVars : TypeVars = myOwnedVars
93
92
def ownedVars_= (vs : TypeVars ): Unit = myOwnedVars = vs
94
93
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
-
101
94
private var upLevels : LevelMap = _
102
95
103
96
/** Initializes all fields except reporter, isCommittable, which need to be
@@ -110,7 +103,6 @@ class TyperState() {
110
103
this .myConstraint = constraint
111
104
this .previousConstraint = constraint
112
105
this .myOwnedVars = SimpleIdentitySet .empty
113
- this .hardVars = SimpleIdentitySet .empty
114
106
this .upLevels = SimpleIdentityMap .empty
115
107
this .isCommitted = false
116
108
this
@@ -122,19 +114,12 @@ class TyperState() {
122
114
val ts = TyperState ().init(this , this .constraint)
123
115
.setReporter(reporter)
124
116
.setCommittable(committable)
125
- ts.hardVars = this .hardVars
126
117
ts.upLevels = upLevels
127
118
ts
128
119
129
120
/** The uninstantiated variables */
130
121
def uninstVars : collection.Seq [TypeVar ] = constraint.uninstVars
131
122
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
-
138
123
/** The nestingLevel of `tv` in this typer state */
139
124
def nestingLevel (tv : TypeVar ): Int =
140
125
val own = upLevels(tv)
@@ -195,11 +180,9 @@ class TyperState() {
195
180
constr.println(i " committing $this to $targetState, fromConstr = $constraint, toConstr = ${targetState.constraint}" )
196
181
if targetState.constraint eq previousConstraint then
197
182
targetState.constraint = constraint
198
- targetState.hardVars = hardVars
199
183
if ! ownedVars.isEmpty then ownedVars.foreach(targetState.includeVar)
200
184
else
201
185
targetState.mergeConstraintWith(this )
202
- for tv <- hardVars do targetState.hardVars += tv
203
186
204
187
upLevels.foreachBinding { (tv, level) =>
205
188
if level < targetState.nestingLevel(tv) then
@@ -247,7 +230,9 @@ class TyperState() {
247
230
val tvars = tl.paramRefs.map(other.typeVarOfParam(_)).collect { case tv : TypeVar => tv }
248
231
if this .isCommittable then
249
232
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))
251
236
typeComparer.addToConstraint(tl, tvars)
252
237
}) &&
253
238
// Integrate the additional constraints on type variables from `other`
0 commit comments