[ConstraintSystem] Attempt conjunction before closure result or generic parameter holes

Closure result type or generic parameter associated with such a location
could bw inferred from a body of a multi-statement closure (when inference
is enabled), so we need to give closure a chance to run before attemtping
a hole for such positions in diagnostic mode.
This commit is contained in:
Pavel Yaskevich
2021-10-29 19:58:39 -07:00
parent 8b901544ee
commit aa3b8867a3
3 changed files with 29 additions and 0 deletions

View File

@@ -345,6 +345,19 @@ StepResult ComponentStep::take(bool prevFailed) {
auto *disjunction = CS.selectDisjunction();
auto bestBindings = CS.determineBestBindings();
if (CS.shouldAttemptFixes()) {
if ((bestBindings &&
(bestBindings->forClosureResult() ||
bestBindings->forGenericParameter()) &&
bestBindings->isHole()) &&
!disjunction) {
if (auto *conjunction = CS.selectConjunction()) {
return suspend(
std::make_unique<ConjunctionStep>(CS, conjunction, Solutions));
}
}
}
if (bestBindings &&
(!disjunction || bestBindings->favoredOverDisjunction(disjunction))) {
// Produce a type variable step.