@@ -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,35 +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 () {
326
- auto &cs = CG.getConstraintSystem ();
327
-
328
- // Notify all of the type variables that reference this one.
329
- //
330
- // Since this type variable is going to be replaced with a fixed type
331
- // all of the concrete types that reference it are going to change,
332
- // which means that all of the not-yet-attempted bindings should
333
- // change as well.
334
- return notifyReferencingVars (
335
- [&cs](ConstraintGraphNode &node, Constraint *constraint) {
336
- node.getPotentialBindings ().retract (cs, node.getTypeVariable (), constraint);
337
- });
338
- }
339
-
340
- void ConstraintGraphNode::introduceToInference (Type fixedType) {
341
- auto &cs = CG.getConstraintSystem ();
342
- return updateFixedType (
343
- fixedType,
344
- [&cs](ConstraintGraphNode &node, Constraint *constraint) {
345
- node.getPotentialBindings ().infer (cs, node.getTypeVariable (), constraint);
346
- });
347
- }
348
-
349
341
#pragma mark Graph mutation
350
342
351
343
void ConstraintGraph::removeNode (TypeVariableType *typeVar) {
0 commit comments