[CS] Unify failed constraint recording

Rename `addNewFailingConstraint` to
`recordFailedConstraint`, and call into it
whenever a constraint fails, instead of setting
`failedConstraint`. This ensures that
`-debug-constraints` will always log the constraint
that failed a given scope.

In addition, introduce `retireFailedConstraint`
to cover the common case of retiring a constraint
that just failed.
This commit is contained in:
Hamish Knight
2020-04-09 20:19:57 -07:00
parent 992f035228
commit c39c4e8aad
4 changed files with 40 additions and 39 deletions

View File

@@ -1697,11 +1697,8 @@ void ConstraintSystem::addOverloadSet(ArrayRef<Constraint *> choices,
auto *disjunction =
Constraint::createDisjunction(*this, choices, locator, ForgetChoice);
addUnsolvedConstraint(disjunction);
if (simplifyAppliedOverloads(disjunction, locator)) {
retireConstraint(disjunction);
if (!failedConstraint)
failedConstraint = disjunction;
}
if (simplifyAppliedOverloads(disjunction, locator))
retireFailedConstraint(disjunction);
}
/// If we're resolving an overload set with a decl that has special type