Skip to content

Commit efafe02

Browse files
committed
[ConstraintSystem] SE-0326: Temporarily prevent multi-statement closure inference in result builder contexts
Multi-statement closure inference doesn't play well with result builders at the moment because it expects all of the information from the parent statements to be inferred before solver starts working on the body of a nested closure. Let's prevent inference for nested multi-statement closures until result builders are ported to use conjunctions and solve the body incrementally top-down instead of in one shot.
1 parent bbdbb47 commit efafe02

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5913,8 +5913,13 @@ bool ConstraintSystem::participatesInInference(ClosureExpr *closure) const {
59135913
return false;
59145914

59155915
auto &ctx = closure->getASTContext();
5916-
return !closure->hasEmptyBody() &&
5917-
ctx.TypeCheckerOpts.EnableMultiStatementClosureInference;
5916+
if (closure->hasEmptyBody() ||
5917+
!ctx.TypeCheckerOpts.EnableMultiStatementClosureInference)
5918+
return false;
5919+
5920+
// If body is nested in a parent that has a function builder applied,
5921+
// let's prevent inference until result builders.
5922+
return !isInResultBuilderContext(closure);
59185923
}
59195924

59205925
TypeVarBindingProducer::TypeVarBindingProducer(BindingSet &bindings)

0 commit comments

Comments
 (0)