@@ -107,7 +107,14 @@ void ConstraintGraphNode::addConstraint(Constraint *constraint) {
107
107
assert (ConstraintIndex.count (constraint) == 0 && " Constraint re-insertion" );
108
108
ConstraintIndex[constraint] = Constraints.size ();
109
109
Constraints.push_back (constraint);
110
- introduceToInference (constraint, /* notifyFixedBindings=*/ true );
110
+
111
+ {
112
+ introduceToInference (constraint);
113
+
114
+ notifyReferencedVars ([&](ConstraintGraphNode &referencedVar) {
115
+ referencedVar.introduceToInference (constraint);
116
+ });
117
+ }
111
118
}
112
119
113
120
void ConstraintGraphNode::removeConstraint (Constraint *constraint) {
@@ -119,8 +126,13 @@ void ConstraintGraphNode::removeConstraint(Constraint *constraint) {
119
126
ConstraintIndex.erase (pos);
120
127
assert (Constraints[index] == constraint && " Mismatched constraint" );
121
128
122
- retractFromInference (constraint,
123
- /* notifyFixedBindings=*/ true );
129
+ {
130
+ retractFromInference (constraint);
131
+
132
+ notifyReferencedVars ([&](ConstraintGraphNode &referencedVar) {
133
+ referencedVar.retractFromInference (constraint);
134
+ });
135
+ }
124
136
125
137
// If this is the last constraint, just pop it off the list and we're done.
126
138
unsigned lastIndex = Constraints.size ()-1 ;
@@ -160,8 +172,7 @@ void ConstraintGraphNode::notifyReferencingVars() const {
160
172
affectedVar->getImpl ().getRepresentative (/* record=*/ nullptr );
161
173
162
174
if (!repr->getImpl ().getFixedType (/* record=*/ nullptr ))
163
- CG[repr].reintroduceToInference (constraint,
164
- /* notifyReferencedVars=*/ false );
175
+ CG[repr].reintroduceToInference (constraint);
165
176
}
166
177
}
167
178
};
@@ -217,7 +228,11 @@ void ConstraintGraphNode::addToEquivalenceClass(
217
228
auto &node = CG[newMember];
218
229
219
230
for (auto *constraint : node.getConstraints ()) {
220
- introduceToInference (constraint, /* notifyReferencedVars=*/ true );
231
+ introduceToInference (constraint);
232
+
233
+ notifyReferencedVars ([&](ConstraintGraphNode &referencedVar) {
234
+ referencedVar.introduceToInference (constraint);
235
+ });
221
236
}
222
237
223
238
node.notifyReferencingVars ();
@@ -296,52 +311,51 @@ static bool isUsefulForReferencedVars(Constraint *constraint) {
296
311
}
297
312
}
298
313
299
- void ConstraintGraphNode::introduceToInference (Constraint *constraint,
300
- bool notifyReferencedVars) {
314
+ void ConstraintGraphNode::introduceToInference (Constraint *constraint) {
301
315
if (forRepresentativeVar ()) {
302
316
auto fixedType = TypeVar->getImpl ().getFixedType (/* record=*/ nullptr );
303
317
if (!fixedType)
304
318
getCurrentBindings ().infer (constraint);
305
319
} else {
306
320
auto *repr =
307
321
getTypeVariable ()->getImpl ().getRepresentative (/* record=*/ nullptr );
308
- CG[repr].introduceToInference (constraint, /* notifyReferencedVars= */ false );
322
+ CG[repr].introduceToInference (constraint);
309
323
}
310
324
325
+ /*
311
326
if (!notifyReferencedVars || !isUsefulForReferencedVars(constraint))
312
327
return;
313
328
314
329
this->notifyReferencedVars([&](ConstraintGraphNode &referencedVar) {
315
- referencedVar.introduceToInference (constraint,
316
- /* notifyReferencedVars=*/ false );
330
+ referencedVar.introduceToInference(constraint);
317
331
});
332
+ */
318
333
}
319
334
320
- void ConstraintGraphNode::retractFromInference (Constraint *constraint,
321
- bool notifyReferencedVars) {
335
+ void ConstraintGraphNode::retractFromInference (Constraint *constraint) {
322
336
if (forRepresentativeVar ()) {
323
337
auto fixedType = TypeVar->getImpl ().getFixedType (/* record=*/ nullptr );
324
338
if (!fixedType)
325
339
getCurrentBindings ().retract (constraint);
326
340
} else {
327
341
auto *repr =
328
342
getTypeVariable ()->getImpl ().getRepresentative (/* record=*/ nullptr );
329
- CG[repr].retractFromInference (constraint, /* notifyReferencedVars= */ false );
343
+ CG[repr].retractFromInference (constraint);
330
344
}
331
345
346
+ /*
332
347
if (!notifyReferencedVars || !isUsefulForReferencedVars(constraint))
333
348
return;
334
349
335
350
this->notifyReferencedVars([&](ConstraintGraphNode &referencedVar) {
336
- referencedVar.retractFromInference (constraint,
337
- /* notifyReferencedVars=*/ false );
351
+ referencedVar.retractFromInference(constraint);
338
352
});
353
+ */
339
354
}
340
355
341
- void ConstraintGraphNode::reintroduceToInference (Constraint *constraint,
342
- bool notifyReferencedVars) {
343
- retractFromInference (constraint, notifyReferencedVars);
344
- introduceToInference (constraint, notifyReferencedVars);
356
+ void ConstraintGraphNode::reintroduceToInference (Constraint *constraint) {
357
+ retractFromInference (constraint);
358
+ introduceToInference (constraint);
345
359
}
346
360
347
361
void ConstraintGraphNode::introduceToInference (Type fixedType) {
@@ -367,8 +381,7 @@ void ConstraintGraphNode::introduceToInference(Type fixedType) {
367
381
// all of the constraints that reference bound type variable.
368
382
for (auto *constraint : getConstraints ()) {
369
383
if (isUsefulForReferencedVars (constraint))
370
- node.reintroduceToInference (constraint,
371
- /* notifyReferencedVars=*/ false );
384
+ node.reintroduceToInference (constraint);
372
385
}
373
386
}
374
387
}
0 commit comments