Skip to content

Commit 61575d9

Browse files
committed
Sema: Remove a few isRecordingChanges() checks to tighten invariants
In these places we now assert if we attempt to record a change during an active undo.
1 parent 9115a46 commit 61575d9

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,9 +2412,8 @@ class ConstraintSystem {
24122412
void recordDefaultedConstraint(ConstraintLocator *locator) {
24132413
bool inserted = DefaultedConstraints.insert(locator).second;
24142414
if (inserted) {
2415-
if (isRecordingChanges()) {
2415+
if (solverState)
24162416
recordChange(SolverTrail::Change::recordedDefaultedConstraint(locator));
2417-
}
24182417
}
24192418
}
24202419

@@ -3177,7 +3176,7 @@ class ConstraintSystem {
31773176

31783177
if (oldType.getPointer() != type.getPointer()) {
31793178
// Record the fact that we assigned a type to this node.
3180-
if (isRecordingChanges())
3179+
if (solverState)
31813180
recordChange(SolverTrail::Change::recordedNodeType(node, oldType));
31823181
}
31833182
}
@@ -3215,7 +3214,7 @@ class ConstraintSystem {
32153214
entry = T;
32163215

32173216
if (oldType.getPointer() != T.getPointer()) {
3218-
if (isRecordingChanges()) {
3217+
if (solverState) {
32193218
recordChange(
32203219
SolverTrail::Change::recordedKeyPathComponentType(
32213220
KP, I, oldType));

lib/Sema/ConstraintSystem.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void ConstraintSystem::addConversionRestriction(
266266
if (!inserted)
267267
return;
268268

269-
if (isRecordingChanges()) {
269+
if (solverState) {
270270
recordChange(SolverTrail::Change::addedConversionRestriction(
271271
srcType, dstType));
272272
}
@@ -284,7 +284,7 @@ void ConstraintSystem::addFix(ConstraintFix *fix) {
284284
if (!inserted)
285285
return;
286286

287-
if (isRecordingChanges())
287+
if (solverState)
288288
recordChange(SolverTrail::Change::addedFix(fix));
289289
}
290290

@@ -304,7 +304,7 @@ void ConstraintSystem::recordDisjunctionChoice(
304304
return;
305305
}
306306

307-
if (isRecordingChanges()) {
307+
if (solverState) {
308308
recordChange(SolverTrail::Change::recordedDisjunctionChoice(
309309
locator, index));
310310
}
@@ -316,7 +316,7 @@ void ConstraintSystem::recordAppliedDisjunction(
316316
auto inserted = AppliedDisjunctions.insert(
317317
std::make_pair(locator, fnType));
318318
if (inserted.second) {
319-
if (isRecordingChanges()) {
319+
if (solverState) {
320320
recordChange(SolverTrail::Change::recordedAppliedDisjunction(locator));
321321
}
322322
}
@@ -854,7 +854,7 @@ void ConstraintSystem::recordOpenedExistentialType(
854854
ConstraintLocator *locator, OpenedArchetypeType *opened) {
855855
bool inserted = OpenedExistentialTypes.insert({locator, opened}).second;
856856
if (inserted) {
857-
if (isRecordingChanges())
857+
if (solverState)
858858
recordChange(SolverTrail::Change::recordedOpenedExistentialType(locator));
859859
}
860860
}
@@ -895,7 +895,7 @@ void ConstraintSystem::recordPackExpansionEnvironment(
895895
ConstraintLocator *locator, std::pair<UUID, Type> uuidAndShape) {
896896
bool inserted = PackExpansionEnvironments.insert({locator, uuidAndShape}).second;
897897
if (inserted) {
898-
if (isRecordingChanges()) {
898+
if (solverState) {
899899
recordChange(
900900
SolverTrail::Change::recordedPackExpansionEnvironment(locator));
901901
}
@@ -913,7 +913,7 @@ void ConstraintSystem::addPackEnvironment(PackElementExpr *packElement,
913913
bool inserted =
914914
PackEnvironments.insert({packElement, packExpansion}).second;
915915
if (inserted) {
916-
if (isRecordingChanges())
916+
if (solverState)
917917
recordChange(SolverTrail::Change::recordedPackEnvironment(packElement));
918918
}
919919
}
@@ -1279,7 +1279,7 @@ void ConstraintSystem::recordOpenedPackExpansionType(PackExpansionType *expansio
12791279
TypeVariableType *expansionVar) {
12801280
bool inserted = OpenedPackExpansionTypes.insert({expansion, expansionVar}).second;
12811281
if (inserted) {
1282-
if (isRecordingChanges())
1282+
if (solverState)
12831283
recordChange(SolverTrail::Change::recordedOpenedPackExpansionType(expansion));
12841284
}
12851285
}
@@ -1688,7 +1688,7 @@ void ConstraintSystem::recordOpenedType(
16881688
ConstraintLocator *locator, ArrayRef<OpenedType> openedTypes) {
16891689
bool inserted = OpenedTypes.insert({locator, openedTypes}).second;
16901690
if (inserted) {
1691-
if (isRecordingChanges())
1691+
if (solverState)
16921692
recordChange(SolverTrail::Change::recordedOpenedTypes(locator));
16931693
}
16941694
}
@@ -7443,7 +7443,7 @@ void ConstraintSystem::recordFixedRequirement(GenericTypeParamType *GP,
74437443
bool inserted = FixedRequirements.insert(
74447444
std::make_tuple(GP, reqKind, requirementTy.getPointer())).second;
74457445
if (inserted) {
7446-
if (isRecordingChanges()) {
7446+
if (solverState) {
74477447
recordChange(SolverTrail::Change::addedFixedRequirement(
74487448
GP, reqKind, requirementTy));
74497449
}

0 commit comments

Comments
 (0)