mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user