@@ -339,19 +339,22 @@ class DependentComponentSplitterStep final : public SolverStep {
339339class ComponentStep final : public SolverStep {
340340 class Scope {
341341 ConstraintSystem &CS;
342- ConstraintSystem::SolverScope * SolverScope;
342+ std::optional< ConstraintSystem::SolverScope> SolverScope;
343343
344344 SetVector<TypeVariableType *> TypeVars;
345345 unsigned prevPartialSolutionFixes = 0 ;
346346
347347 // The component this scope is associated with.
348348 ComponentStep &Component;
349349
350+ Scope (const Scope &) = delete ;
351+ Scope &operator =(const Scope &) = delete ;
352+
350353 public:
351- Scope (ComponentStep &component);
354+ explicit Scope (ComponentStep &component);
352355
353356 ~Scope () {
354- delete SolverScope; // rewind back all of the changes.
357+ SolverScope. reset () ; // rewind back all of the changes.
355358 CS.solverState ->numPartialSolutionFixes = prevPartialSolutionFixes;
356359
357360 // return all of the saved type variables back to the system.
@@ -383,7 +386,7 @@ class ComponentStep final : public SolverStep {
383386
384387 // / If this step depends on other smaller steps to be solved first
385388 // / we need to keep active scope until all of the work is done.
386- std::unique_ptr <Scope> ComponentScope = nullptr ;
389+ std::optional <Scope> ComponentScope;
387390
388391 // / Type variables and constraints "in scope" of this step.
389392 TinyPtrVector<TypeVariableType *> TypeVars;
@@ -474,7 +477,7 @@ class ComponentStep final : public SolverStep {
474477 log << " (solving component #" << Index << ' \n ' ;
475478 }
476479
477- ComponentScope = std::make_unique<Scope> (*this );
480+ ComponentScope. emplace (*this );
478481
479482 if (CS.isDebugMode ()) {
480483 auto &log = getDebugLogger ();
@@ -834,7 +837,7 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
834837 // / this scope would be initialized once all of the
835838 // / elements are successfully solved to continue solving
836839 // / along the current path as-if there was no conjunction.
837- std::unique_ptr <Scope> IsolationScope = nullptr ;
840+ std::optional <Scope> IsolationScope;
838841
839842 public:
840843 SolverSnapshot (ConstraintSystem &cs, Constraint *conjunction)
@@ -862,7 +865,7 @@ class ConjunctionStep : public BindingStep<ConjunctionElementProducer> {
862865
863866 // Establish isolation scope so that conjunction solution
864867 // and follow-up steps could be rolled back.
865- IsolationScope = std::make_unique<Scope> (CS);
868+ IsolationScope. emplace (CS);
866869
867870 // Apply solution inferred for the conjunction.
868871 replaySolution (solution);
0 commit comments