Skip to content

Commit 338ad30

Browse files
committed
Sema: Tighten an invariant in ConstraintGraph
These functions are never called while undoing a change; so we want to assert if we have an active undo instead of silently not recording the change.
1 parent 53794d3 commit 338ad30

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/Sema/ConstraintGraph.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ void ConstraintGraph::addConstraint(Constraint *constraint) {
399399
auto referencedTypeVars = constraint->getTypeVariables();
400400
for (auto typeVar : referencedTypeVars) {
401401
// Record the change, if there are active scopes.
402-
if (CS.isRecordingChanges())
402+
if (CS.solverState)
403403
CS.recordChange(SolverTrail::Change::AddedConstraint(typeVar, constraint));
404404

405405
addConstraint(typeVar, constraint);
@@ -419,7 +419,7 @@ void ConstraintGraph::addConstraint(Constraint *constraint) {
419419
// track it as such.
420420
if (referencedTypeVars.empty()) {
421421
// Record the change, if there are active scopes.
422-
if (CS.isRecordingChanges())
422+
if (CS.solverState)
423423
CS.recordChange(SolverTrail::Change::AddedConstraint(nullptr, constraint));
424424

425425
addConstraint(nullptr, constraint);
@@ -454,7 +454,7 @@ void ConstraintGraph::removeConstraint(Constraint *constraint) {
454454
}
455455

456456
// Record the change, if there are active scopes.
457-
if (CS.isRecordingChanges())
457+
if (CS.solverState)
458458
CS.recordChange(SolverTrail::Change::RemovedConstraint(typeVar, constraint));
459459

460460
removeConstraint(typeVar, constraint);
@@ -463,7 +463,7 @@ void ConstraintGraph::removeConstraint(Constraint *constraint) {
463463
// If this is an orphaned constraint, remove it from the list.
464464
if (referencedTypeVars.empty()) {
465465
// Record the change, if there are active scopes.
466-
if (CS.isRecordingChanges())
466+
if (CS.solverState)
467467
CS.recordChange(SolverTrail::Change::RemovedConstraint(nullptr, constraint));
468468

469469
removeConstraint(nullptr, constraint);

0 commit comments

Comments
 (0)