Skip to content

Commit 9cb2c05

Browse files
committed
[CodeCompletion] Fix a crash in context type analysis
'IfExpr' (ternary expression) does not have condition part before sequence folding. Add a guard to avoid a crash. rdar://problem/59344203
1 parent 0976e39 commit 9cb2c05

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ class ExprContextAnalyzer {
647647
}
648648
case ExprKind::If: {
649649
auto *IE = cast<IfExpr>(Parent);
650-
if (SM.rangeContains(IE->getCondExpr()->getSourceRange(),
650+
if (IE->isFolded() &&
651+
SM.rangeContains(IE->getCondExpr()->getSourceRange(),
651652
ParsedExpr->getSourceRange())) {
652653
recordPossibleType(Context.getBoolDecl()->getDeclaredInterfaceType());
653654
break;

0 commit comments

Comments
 (0)