@@ -885,34 +885,17 @@ StepResult ConjunctionStep::resume(bool prevFailed) {
885885 log << " (applying conjunction result to outer context\n " ;
886886 }
887887
888- // Restore constraint system state before conjunction.
889- //
890- // Note that this doesn't include conjunction constraint
891- // itself because we don't want to re-solve it at this
892- // point.
893888 assert (
894889 Snapshot &&
895890 " Isolated conjunction requires a snapshot of the constraint system" );
896- Snapshot->setupOuterContext (Solutions.pop_back_val ());
897891
898- // Restore best score, since upcoming step is going to
899- // work with outer scope in relation to the conjunction.
900- CS.solverState ->BestScore = BestScore;
901-
902- // Active all of the previously out-of-scope constraints
903- // because conjunction can propagate type information up
904- // by allowing its elements to reference type variables
905- // from outer scope (e.g. variable declarations and or captures).
906- {
907- CS.ActiveConstraints .splice (CS.ActiveConstraints .end (),
908- CS.InactiveConstraints );
909- for (auto &constraint : CS.ActiveConstraints )
910- constraint.setActive (true );
911- }
892+ // Restore outer type variables and prepare to solve
893+ // constraints associated with outer context together
894+ // with information deduced from the conjunction.
895+ Snapshot->setupOuterContext (Solutions.pop_back_val ());
912896
913- // Restore score to the one before conjunction. This has
914- // be done after solution, reached for the body, is applied.
915- CS.CurrentScore = CurrentScore;
897+ // Pretend that conjunction never happend.
898+ restoreOuterState ();
916899
917900 // Now that all of the information from the conjunction has
918901 // been applied, let's attempt to solve the outer scope.
@@ -923,3 +906,24 @@ StepResult ConjunctionStep::resume(bool prevFailed) {
923906 // Attempt next conjunction choice.
924907 return take (prevFailed);
925908}
909+
910+ void ConjunctionStep::restoreOuterState () const {
911+ // Restore best score, since upcoming step is going to
912+ // work with outer scope in relation to the conjunction.
913+ CS.solverState ->BestScore = BestScore;
914+
915+ // Active all of the previously out-of-scope constraints
916+ // because conjunction can propagate type information up
917+ // by allowing its elements to reference type variables
918+ // from outer scope (e.g. variable declarations and or captures).
919+ {
920+ CS.ActiveConstraints .splice (CS.ActiveConstraints .end (),
921+ CS.InactiveConstraints );
922+ for (auto &constraint : CS.ActiveConstraints )
923+ constraint.setActive (true );
924+ }
925+
926+ // Restore score to the one before conjunction. This has
927+ // be done after solution, reached for the body, is applied.
928+ CS.CurrentScore = CurrentScore;
929+ }
0 commit comments