@@ -138,7 +138,7 @@ void ConstraintGraphNode::removeConstraint(Constraint *constraint) {
138
138
Constraints.pop_back ();
139
139
}
140
140
141
- void ConstraintGraphNode::updateAdjacentVars () const {
141
+ void ConstraintGraphNode::notifyReferencingVars () const {
142
142
SmallVector<TypeVariableType *, 4 > stack;
143
143
144
144
stack.push_back (TypeVar);
@@ -161,7 +161,7 @@ void ConstraintGraphNode::updateAdjacentVars() const {
161
161
162
162
if (!repr->getImpl ().getFixedType (/* record=*/ nullptr ))
163
163
CG[repr].reintroduceToInference (constraint,
164
- /* notifyFixedBindings =*/ false );
164
+ /* notifyReferencedVars =*/ false );
165
165
}
166
166
}
167
167
};
@@ -210,10 +210,10 @@ void ConstraintGraphNode::addToEquivalenceClass(
210
210
auto &node = CG[newMember];
211
211
212
212
for (auto *constraint : node.getConstraints ()) {
213
- introduceToInference (constraint, /* notifyFixedBindings =*/ true );
213
+ introduceToInference (constraint, /* notifyReferencedVars =*/ true );
214
214
}
215
215
216
- node.updateAdjacentVars ();
216
+ node.notifyReferencingVars ();
217
217
}
218
218
}
219
219
}
@@ -237,7 +237,7 @@ void ConstraintGraphNode::truncateEquivalenceClass(unsigned prevSize) {
237
237
238
238
// Re-infer bindings all all of the newly made representatives.
239
239
for (auto *typeVar : disconnectedVars)
240
- CG[typeVar].updateAdjacentVars ();
240
+ CG[typeVar].notifyReferencingVars ();
241
241
}
242
242
}
243
243
@@ -288,51 +288,51 @@ static bool isUsefulForReferencedVars(Constraint *constraint) {
288
288
}
289
289
290
290
void ConstraintGraphNode::introduceToInference (Constraint *constraint,
291
- bool notifyFixedBindings ) {
291
+ bool notifyReferencedVars ) {
292
292
if (forRepresentativeVar ()) {
293
293
auto fixedType = TypeVar->getImpl ().getFixedType (/* record=*/ nullptr );
294
294
if (!fixedType || fixedType->isTypeVariableOrMember ())
295
295
getCurrentBindings ().infer (constraint);
296
296
} else {
297
297
auto *repr =
298
298
getTypeVariable ()->getImpl ().getRepresentative (/* record=*/ nullptr );
299
- CG[repr].introduceToInference (constraint, /* notifyFixedBindings =*/ false );
299
+ CG[repr].introduceToInference (constraint, /* notifyReferencedVars =*/ false );
300
300
}
301
301
302
- if (!notifyFixedBindings || !isUsefulForReferencedVars (constraint))
302
+ if (!notifyReferencedVars || !isUsefulForReferencedVars (constraint))
303
303
return ;
304
304
305
305
for (auto *fixedBinding : getReferencedVars ()) {
306
306
CG[fixedBinding].introduceToInference (constraint,
307
- /* notifyFixedBindings =*/ false );
307
+ /* notifyReferencedVars =*/ false );
308
308
}
309
309
}
310
310
311
311
void ConstraintGraphNode::retractFromInference (Constraint *constraint,
312
- bool notifyFixedBindings ) {
312
+ bool notifyReferencedVars ) {
313
313
if (forRepresentativeVar ()) {
314
314
auto fixedType = TypeVar->getImpl ().getFixedType (/* record=*/ nullptr );
315
315
if (!fixedType || fixedType->isTypeVariableOrMember ())
316
316
getCurrentBindings ().retract (constraint);
317
317
} else {
318
318
auto *repr =
319
319
getTypeVariable ()->getImpl ().getRepresentative (/* record=*/ nullptr );
320
- CG[repr].retractFromInference (constraint, /* notifyFixedBindings =*/ false );
320
+ CG[repr].retractFromInference (constraint, /* notifyReferencedVars =*/ false );
321
321
}
322
322
323
- if (!notifyFixedBindings || !isUsefulForReferencedVars (constraint))
323
+ if (!notifyReferencedVars || !isUsefulForReferencedVars (constraint))
324
324
return ;
325
325
326
326
for (auto *fixedBinding : getReferencedVars ()) {
327
327
CG[fixedBinding].retractFromInference (constraint,
328
- /* notifyFixedBindings =*/ false );
328
+ /* notifyReferencedVars =*/ false );
329
329
}
330
330
}
331
331
332
332
void ConstraintGraphNode::reintroduceToInference (Constraint *constraint,
333
- bool notifyFixedBindings ) {
334
- retractFromInference (constraint, notifyFixedBindings );
335
- introduceToInference (constraint, notifyFixedBindings );
333
+ bool notifyReferencedVars ) {
334
+ retractFromInference (constraint, notifyReferencedVars );
335
+ introduceToInference (constraint, notifyReferencedVars );
336
336
}
337
337
338
338
void ConstraintGraphNode::resetBindingSet () {
@@ -557,8 +557,9 @@ void ConstraintGraph::bindTypeVariable(TypeVariableType *typeVar, Type fixed) {
557
557
// Newly referred vars need to re-introduce all constraints associated
558
558
// with this type variable.
559
559
for (auto *constraint : (*this )[typeVar].getConstraints ()) {
560
- otherNode.reintroduceToInference (constraint,
561
- /* notifyFixedBindings=*/ false );
560
+ if (isUsefulForReferencedVars (constraint))
561
+ otherNode.reintroduceToInference (constraint,
562
+ /* notifyReferencedVars=*/ false );
562
563
}
563
564
}
564
565
}
@@ -568,7 +569,7 @@ void ConstraintGraph::bindTypeVariable(TypeVariableType *typeVar, Type fixed) {
568
569
// whole equivalence class of the current type variable and all of its
569
570
// fixed bindings.
570
571
{
571
- (*this )[typeVar].updateAdjacentVars ();
572
+ (*this )[typeVar].notifyReferencingVars ();
572
573
}
573
574
}
574
575
@@ -580,7 +581,7 @@ void ConstraintGraph::unbindTypeVariable(TypeVariableType *typeVar, Type fixed)
580
581
{
581
582
auto &node = (*this )[typeVar];
582
583
583
- node.updateAdjacentVars ();
584
+ node.notifyReferencingVars ();
584
585
585
586
llvm::SmallPtrSet<TypeVariableType *, 4 > typeVars;
586
587
0 commit comments