@@ -287,17 +287,33 @@ void ConstraintGraphNode::removeReferencedBy(TypeVariableType *typeVar) {
287
287
}
288
288
}
289
289
290
- void ConstraintGraphNode::updateFixedType (
291
- Type fixedType,
292
- llvm::function_ref<void (ConstraintGraphNode &,
293
- Constraint *)> notification) const {
290
+ void ConstraintGraphNode::retractFromInference () {
291
+ auto &cs = CG.getConstraintSystem ();
292
+
293
+ // Notify all of the type variables that reference this one.
294
+ //
295
+ // Since this type variable is going to be replaced with a fixed type
296
+ // all of the concrete types that reference it are going to change,
297
+ // which means that all of the not-yet-attempted bindings should
298
+ // change as well.
299
+ return notifyReferencingVars (
300
+ [&cs](ConstraintGraphNode &node, Constraint *constraint) {
301
+ node.getPotentialBindings ().retract (cs, node.getTypeVariable (), constraint);
302
+ });
303
+ }
304
+
305
+ void ConstraintGraphNode::introduceToInference (Type fixedType) {
306
+ auto &cs = CG.getConstraintSystem ();
307
+
294
308
// Notify all of the type variables that reference this one.
295
309
//
296
310
// Since this type variable has been replaced with a fixed type
297
311
// all of the concrete types that reference it are going to change,
298
312
// which means that all of the not-yet-attempted bindings should
299
313
// change as well.
300
- notifyReferencingVars (notification);
314
+ notifyReferencingVars ([&cs](ConstraintGraphNode &node, Constraint *constraint) {
315
+ node.getPotentialBindings ().infer (cs, node.getTypeVariable (), constraint);
316
+ });
301
317
302
318
if (!fixedType->hasTypeVariable ())
303
319
return ;
@@ -317,29 +333,11 @@ void ConstraintGraphNode::updateFixedType(
317
333
// all of the constraints that reference bound type variable.
318
334
for (auto *constraint : getConstraints ()) {
319
335
if (isUsefulForReferencedVars (constraint))
320
- notification ( node, constraint);
336
+ node. getPotentialBindings (). infer (cs, node. getTypeVariable () , constraint);
321
337
}
322
338
}
323
339
}
324
340
325
- void ConstraintGraphNode::retractFromInference (Type fixedType) {
326
- auto &cs = CG.getConstraintSystem ();
327
- return updateFixedType (
328
- fixedType,
329
- [&cs](ConstraintGraphNode &node, Constraint *constraint) {
330
- node.getPotentialBindings ().retract (cs, node.getTypeVariable (), constraint);
331
- });
332
- }
333
-
334
- void ConstraintGraphNode::introduceToInference (Type fixedType) {
335
- auto &cs = CG.getConstraintSystem ();
336
- return updateFixedType (
337
- fixedType,
338
- [&cs](ConstraintGraphNode &node, Constraint *constraint) {
339
- node.getPotentialBindings ().infer (cs, node.getTypeVariable (), constraint);
340
- });
341
- }
342
-
343
341
#pragma mark Graph mutation
344
342
345
343
void ConstraintGraph::removeNode (TypeVariableType *typeVar) {
@@ -523,8 +521,8 @@ void ConstraintGraph::bindTypeVariable(TypeVariableType *typeVar, Type fixed) {
523
521
}
524
522
}
525
523
526
- void ConstraintGraph::retractFromInference (TypeVariableType *typeVar, Type fixed ) {
527
- (*this )[typeVar].retractFromInference (fixed );
524
+ void ConstraintGraph::retractFromInference (TypeVariableType *typeVar) {
525
+ (*this )[typeVar].retractFromInference ();
528
526
}
529
527
530
528
void ConstraintGraph::introduceToInference (TypeVariableType *typeVar, Type fixed) {
0 commit comments