mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: Remove similar weirdness from ~ConjunctionStep
This commit is contained in:
@@ -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!");
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user