@@ -287,17 +287,33 @@ void ConstraintGraphNode::removeReferencedBy(TypeVariableType *typeVar) {
287287 }
288288}
289289
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+
294308 // Notify all of the type variables that reference this one.
295309 //
296310 // Since this type variable has been replaced with a fixed type
297311 // all of the concrete types that reference it are going to change,
298312 // which means that all of the not-yet-attempted bindings should
299313 // change as well.
300- notifyReferencingVars (notification);
314+ notifyReferencingVars ([&cs](ConstraintGraphNode &node, Constraint *constraint) {
315+ node.getPotentialBindings ().infer (cs, node.getTypeVariable (), constraint);
316+ });
301317
302318 if (!fixedType->hasTypeVariable ())
303319 return ;
@@ -317,29 +333,11 @@ void ConstraintGraphNode::updateFixedType(
317333 // all of the constraints that reference bound type variable.
318334 for (auto *constraint : getConstraints ()) {
319335 if (isUsefulForReferencedVars (constraint))
320- notification ( node, constraint);
336+ node. getPotentialBindings (). infer (cs, node. getTypeVariable () , constraint);
321337 }
322338 }
323339}
324340
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-
343341#pragma mark Graph mutation
344342
345343void ConstraintGraph::removeNode (TypeVariableType *typeVar) {
@@ -523,8 +521,8 @@ void ConstraintGraph::bindTypeVariable(TypeVariableType *typeVar, Type fixed) {
523521 }
524522}
525523
526- void ConstraintGraph::retractFromInference (TypeVariableType *typeVar, Type fixed ) {
527- (*this )[typeVar].retractFromInference (fixed );
524+ void ConstraintGraph::retractFromInference (TypeVariableType *typeVar) {
525+ (*this )[typeVar].retractFromInference ();
528526}
529527
530528void ConstraintGraph::introduceToInference (TypeVariableType *typeVar, Type fixed) {
0 commit comments