Skip to content

Commit 58fdc4f

Browse files
committed
Sema: ConstraintGraph::retractFromInference() doesn't need the new fixed type
1 parent f0f5ffc commit 58fdc4f

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

include/swift/Sema/ConstraintGraph.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class ConstraintGraphNode {
148148

149149
/// Perform graph updates that must be undone after we bind a fixed type
150150
/// to a type variable.
151-
void retractFromInference(Type fixedType);
151+
void retractFromInference();
152152

153153
/// Perform graph updates that must be undone before we bind a fixed type
154154
/// to a type variable.
@@ -294,7 +294,7 @@ class ConstraintGraph {
294294

295295
/// Perform graph updates that must be undone after we bind a fixed type
296296
/// to a type variable.
297-
void retractFromInference(TypeVariableType *typeVar, Type fixedType);
297+
void retractFromInference(TypeVariableType *typeVar);
298298

299299
/// Perform graph updates that must be undone before we bind a fixed type
300300
/// to a type variable.

lib/Sema/ConstraintGraph.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,16 @@ void ConstraintGraphNode::updateFixedType(
322322
}
323323
}
324324

325-
void ConstraintGraphNode::retractFromInference(Type fixedType) {
325+
void ConstraintGraphNode::retractFromInference() {
326326
auto &cs = CG.getConstraintSystem();
327-
return updateFixedType(
328-
fixedType,
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(
329335
[&cs](ConstraintGraphNode &node, Constraint *constraint) {
330336
node.getPotentialBindings().retract(cs, node.getTypeVariable(), constraint);
331337
});
@@ -523,8 +529,8 @@ void ConstraintGraph::bindTypeVariable(TypeVariableType *typeVar, Type fixed) {
523529
}
524530
}
525531

526-
void ConstraintGraph::retractFromInference(TypeVariableType *typeVar, Type fixed) {
527-
(*this)[typeVar].retractFromInference(fixed);
532+
void ConstraintGraph::retractFromInference(TypeVariableType *typeVar) {
533+
(*this)[typeVar].retractFromInference();
528534
}
529535

530536
void ConstraintGraph::introduceToInference(TypeVariableType *typeVar, Type fixed) {

lib/Sema/ConstraintSystem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void ConstraintSystem::assignFixedType(TypeVariableType *typeVar, Type type,
217217
assert(!type->hasError() &&
218218
"Should not be assigning a type involving ErrorType!");
219219

220-
CG.retractFromInference(typeVar, type);
220+
CG.retractFromInference(typeVar);
221221
typeVar->getImpl().assignFixedType(type, getTrail());
222222

223223
if (!updateState)

0 commit comments

Comments
 (0)