Sema: Remove similar weirdness from ~ConjunctionStep

This commit is contained in:
Slava Pestov
2024-10-21 17:21:09 -04:00
parent e0b6a96f0e
commit 65def070dc
2 changed files with 4 additions and 21 deletions

View File

@@ -430,10 +430,12 @@ StepResult ComponentStep::take(bool prevFailed) {
return suspend(
std::make_unique<DisjunctionStep>(CS, disjunction, Solutions));
}
case StepKind::Conjunction:
case StepKind::Conjunction: {
CS.retireConstraint(conjunction);
return suspend(
std::make_unique<ConjunctionStep>(CS, conjunction, Solutions));
}
}
llvm_unreachable("Unhandled case in switch!");
}

View File

@@ -202,18 +202,6 @@ protected:
return StepResult::unsolved(followup);
}
/// Erase constraint from the constraint system (include constraint graph)
/// and return the constraint which follows it.
ConstraintList::iterator erase(Constraint *constraint) {
CS.CG.removeConstraint(constraint);
return CS.InactiveConstraints.erase(constraint);
}
void restore(ConstraintList::iterator &iterator, Constraint *constraint) {
CS.InactiveConstraints.insert(iterator, constraint);
CS.CG.addConstraint(constraint);
}
void recordDisjunctionChoice(ConstraintLocator *disjunctionLocator,
unsigned index) const {
CS.recordDisjunctionChoice(disjunctionLocator, index);
@@ -915,10 +903,6 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
/// Conjunction constraint associated with this step.
Constraint *Conjunction;
/// Position of the conjunction in the inactive constraints
/// list which is required to re-instate it to the system
/// after this step is done.
ConstraintList::iterator AfterConjunction;
/// Indicates that one of the elements failed inference.
bool HadFailure = false;
@@ -946,7 +930,7 @@ public:
conjunction->isIsolated() ? IsolatedSolutions : solutions),
BestScore(getBestScore()),
OuterScopeCount(cs.CountScopes, 0), Conjunction(conjunction),
AfterConjunction(erase(conjunction)), OuterSolutions(solutions) {
OuterSolutions(solutions) {
assert(conjunction->getKind() == ConstraintKind::Conjunction);
// Make a snapshot of the constraint system state before conjunction.
@@ -965,9 +949,6 @@ public:
// Return all of the type variables and constraints back.
Snapshot.reset();
// Restore conjunction constraint.
restore(AfterConjunction, Conjunction);
// Restore best score only if conjunction fails because
// successful outcome should keep a score set by `restoreOuterState`.
if (HadFailure)