Skip to content

Commit dfe6c34

Browse files
committed
[CSClosure] Avoid creating conjunctions for empty bodies
1 parent 67a7214 commit dfe6c34

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Sema/CSClosure.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ static void createConjunction(ConstraintSystem &cs,
155155
Constraint::createClosureBodyElement(cs, element, context, elementLoc));
156156
}
157157

158+
// It's possible that there are no viable elements in the body,
159+
// because e.g. whole body is an `#if` statement or it only has
160+
// declarations that are checked during solution application.
161+
// In such cases, let's avoid creating a conjunction.
162+
if (constraints.empty())
163+
return;
164+
158165
cs.addUnsolvedConstraint(Constraint::createConjunction(
159166
cs, constraints, isIsolated, locator, referencedVars));
160167
}

0 commit comments

Comments
 (0)