1818#include " swift/Basic/Defer.h"
1919#include " swift/Basic/Statistic.h"
2020#include " swift/Sema/ConstraintGraph.h"
21- #include " swift/Sema/ConstraintGraphScope.h"
2221#include " swift/Sema/ConstraintSystem.h"
2322#include " swift/Sema/CSTrail.h"
2423#include " swift/Basic/Assertions.h"
@@ -69,7 +68,7 @@ ConstraintGraph::lookupNode(TypeVariableType *typeVar) {
6968 TypeVariables.push_back (typeVar);
7069
7170 // Record the change, if there are active scopes.
72- if (ActiveScope )
71+ if (CS. solverState )
7372 CS.solverState ->recordChange (SolverTrail::Change::addedTypeVariable (typeVar));
7473
7574 // If this type variable is not the representative of its equivalence class,
@@ -405,26 +404,6 @@ void ConstraintGraphNode::resetBindingSet() {
405404 }
406405}
407406
408- #pragma mark Graph scope management
409- ConstraintGraphScope::ConstraintGraphScope (ConstraintGraph &CG)
410- : CG(CG), ParentScope(CG.ActiveScope),
411- NumChanges(CG.getConstraintSystem().solverState->Trail.size())
412- {
413- CG.ActiveScope = this ;
414- }
415-
416- ConstraintGraphScope::~ConstraintGraphScope () {
417- // Don't attempt to rollback if constraint system ended up
418- // in an invalid state.
419- if (CG.CS .inInvalidState ())
420- return ;
421-
422- CG.CS .solverState ->Trail .undo (NumChanges);
423-
424- // The active scope is now the parent scope.
425- CG.ActiveScope = ParentScope;
426- }
427-
428407#pragma mark Graph mutation
429408
430409void ConstraintGraph::removeNode (TypeVariableType *typeVar) {
@@ -459,7 +438,7 @@ void ConstraintGraph::addConstraint(Constraint *constraint) {
459438 }
460439
461440 // Record the change, if there are active scopes.
462- if (ActiveScope )
441+ if (CS. solverState )
463442 CS.solverState ->recordChange (SolverTrail::Change::addedConstraint (constraint));
464443}
465444
@@ -485,7 +464,7 @@ void ConstraintGraph::removeConstraint(Constraint *constraint) {
485464 }
486465
487466 // Record the change, if there are active scopes.
488- if (ActiveScope )
467+ if (CS. solverState )
489468 CS.solverState ->recordChange (SolverTrail::Change::removedConstraint (constraint));
490469}
491470
@@ -504,7 +483,7 @@ void ConstraintGraph::mergeNodes(TypeVariableType *typeVar1,
504483 auto typeVarNonRep = typeVar1 == typeVarRep? typeVar2 : typeVar1;
505484
506485 // Record the change, if there are active scopes.
507- if (ActiveScope ) {
486+ if (CS. solverState ) {
508487 CS.solverState ->recordChange (
509488 SolverTrail::Change::extendedEquivalenceClass (
510489 typeVarRep,
@@ -521,7 +500,7 @@ void ConstraintGraph::bindTypeVariable(TypeVariableType *typeVar, Type fixed) {
521500 " Cannot bind to type variable; merge equivalence classes instead" );
522501
523502 // Record the change, if there are active scopes.
524- if (ActiveScope ) {
503+ if (CS. solverState ) {
525504 CS.solverState ->recordChange (
526505 SolverTrail::Change::boundTypeVariable (typeVar, fixed));
527506 }
0 commit comments