mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Record disabled constraints in the trail
This commit is contained in:
@@ -246,6 +246,14 @@ SolverTrail::Change::recordedKeyPathComponentType(const KeyPathExpr *expr,
|
||||
return result;
|
||||
}
|
||||
|
||||
SolverTrail::Change
|
||||
SolverTrail::Change::disabledConstraint(Constraint *constraint) {
|
||||
Change result;
|
||||
result.Kind = ChangeKind::DisabledConstraint;
|
||||
result.TheConstraint.Constraint = constraint;
|
||||
return result;
|
||||
}
|
||||
|
||||
void SolverTrail::Change::undo(ConstraintSystem &cs) const {
|
||||
auto &cg = cs.getConstraintGraph();
|
||||
|
||||
@@ -342,6 +350,11 @@ void SolverTrail::Change::undo(ConstraintSystem &cs) const {
|
||||
case ChangeKind::RecordedKeyPathComponentType:
|
||||
cs.restoreType(KeyPath.Expr, Options, KeyPath.OldType);
|
||||
break;
|
||||
|
||||
case ChangeKind::DisabledConstraint:
|
||||
if (TheConstraint.Constraint->isDisabled())
|
||||
TheConstraint.Constraint->setEnabled();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,6 +543,13 @@ void SolverTrail::Change::dump(llvm::raw_ostream &out,
|
||||
out << "null";
|
||||
out << " for component " << Options << ")\n";
|
||||
break;
|
||||
|
||||
case ChangeKind::DisabledConstraint:
|
||||
out << "(disabled constraint ";
|
||||
TheConstraint.Constraint->print(out, &cs.getASTContext().SourceMgr,
|
||||
indent + 2);
|
||||
out << ")\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user