Skip to content

Commit fba8088

Browse files
committed
[CSClosure] Mark conjunctions representing closure body as isolated
Bodies of multi-statement closures should be handled in isolation because they don't dependent on anything expect parameter/result types from outer context.
1 parent e3aa377 commit fba8088

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/Sema/CSClosure.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,14 @@ static void createConjunction(ConstraintSystem &cs,
105105

106106
if (locator->directlyAt<ClosureExpr>()) {
107107
auto *closure = castToExpr<ClosureExpr>(locator->getAnchor());
108-
109-
// If this is a top level closure, it has to be isolated.
110-
isIsolated = !isa<AbstractClosureExpr>(closure->getParent());
108+
// Conjunction associated with the body of the closure has to
109+
// reference a type variable representing closure type,
110+
// otherwise it would get disconnected from its contextual type.
111111
referencedVars.push_back(cs.getType(closure)->castTo<TypeVariableType>());
112+
// Body of the closure is always isolated from its context, only
113+
// its individual elements are allowed access to type information
114+
// from the ouside e.g. parameters/result type.
115+
isIsolated = true;
112116
}
113117

114118
for (const auto &entry : elements) {

0 commit comments

Comments
 (0)