File tree Expand file tree Collapse file tree
lib/Sema/ConstraintSystem Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -460,6 +460,10 @@ class Constraint {
460460 // / @brief Enable this constraint.
461461 void enable () { _isDisabled = 0 ; }
462462
463+ // / @brief Sets the enabled state of this constraint.
464+ // / @param enabled True to enable the constraint, false to disable it.
465+ void setEnabled (bool enabled) { _isDisabled = !enabled; }
466+
463467 // / @brief Print this constraint to the output stream.
464468 void print () const ;
465469};
Original file line number Diff line number Diff line change @@ -219,8 +219,11 @@ class ConstraintSystem {
219219 // / extracted.
220220 void mapImplicitConversions (Solution *solution);
221221
222- // / @brief Solves all constraints and returns the solution result through
223- // / the provided parameter.
222+ // / @brief Solves all enabled constraints within this local constraint
223+ // / system and returns the solution result through the provided parameter.
224+ // / This method is called within solveConstraints, after simplification and
225+ // / splitting of the constraint system, and before mapping types back to the
226+ // / AST.
224227 // / @param result The solution result to populate with found solutions.
225228 // / @return True if a solution was found, false otherwise.
226229 bool solveLocalConstraints (SolutionResult &result);
Original file line number Diff line number Diff line change @@ -298,10 +298,7 @@ bool ConstraintSystem::solveConstraints()
298298 for (std::size_t i = 0 ; i < colors.size (); ++i) {
299299 // Disable all constraints not in this color
300300 for (auto *constraint : _constraints) {
301- constraint->disable ();
302- }
303- for (auto *constraint : colorConstraints[i]) {
304- constraint->enable ();
301+ constraint->setEnabled (colorConstraints[i].count (constraint));
305302 }
306303 SolutionResult result;
307304 if (!solveLocalConstraints (result)) {
You can’t perform that action at this time.
0 commit comments