diff --git a/lib/Sema/CSStep.cpp b/lib/Sema/CSStep.cpp index 3f6aa1047a0..c8471dd721d 100644 --- a/lib/Sema/CSStep.cpp +++ b/lib/Sema/CSStep.cpp @@ -430,10 +430,12 @@ StepResult ComponentStep::take(bool prevFailed) { return suspend( std::make_unique(CS, disjunction, Solutions)); } - case StepKind::Conjunction: + case StepKind::Conjunction: { + CS.retireConstraint(conjunction); return suspend( std::make_unique(CS, conjunction, Solutions)); } + } llvm_unreachable("Unhandled case in switch!"); } diff --git a/lib/Sema/CSStep.h b/lib/Sema/CSStep.h index aaaec6edf75..a1e7f9c5c17 100644 --- a/lib/Sema/CSStep.h +++ b/lib/Sema/CSStep.h @@ -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 { /// 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)