Skip to content

Commit 2cf365f

Browse files
committed
Sema: Fold ConstraintGraph::updateFixedType() into its last caller
1 parent 58fdc4f commit 2cf365f

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

include/swift/Sema/ConstraintGraph.h

-5
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ class ConstraintGraphNode {
175175
/// Notify all of the type variables referenced by this one about a change.
176176
void notifyReferencedVars(
177177
llvm::function_ref<void(ConstraintGraphNode &)> notification) const;
178-
179-
void updateFixedType(
180-
Type fixedType,
181-
llvm::function_ref<void (ConstraintGraphNode &,
182-
Constraint *)> notification) const;
183178
/// }
184179

185180
/// The constraint graph this node belongs to.

lib/Sema/ConstraintGraph.cpp

+22-30
Original file line numberDiff line numberDiff line change
@@ -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,35 +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() {
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-
349341
#pragma mark Graph mutation
350342

351343
void ConstraintGraph::removeNode(TypeVariableType *typeVar) {

0 commit comments

Comments
 (0)