Skip to content

Commit 8c8b89c

Browse files
committed
[CodeCompletion] Add defensive nullptr check
Prevent crash. rdar://problem/51599533
1 parent 02e1a11 commit 8c8b89c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,15 @@ static bool collectPossibleCalleesForApply(
367367

368368
if (auto *DRE = dyn_cast<DeclRefExpr>(fnExpr)) {
369369
if (auto *decl = DRE->getDecl()) {
370-
auto declType = decl->getInterfaceType();
371-
if (auto *funcType = declType->getAs<AnyFunctionType>())
372-
candidates.emplace_back(funcType, decl);
370+
if (decl->hasInterfaceType())
371+
if (auto *funcType = decl->getInterfaceType()->getAs<AnyFunctionType>())
372+
candidates.emplace_back(funcType, decl);
373373
}
374374
} else if (auto *OSRE = dyn_cast<OverloadSetRefExpr>(fnExpr)) {
375375
for (auto *decl : OSRE->getDecls()) {
376-
auto declType = decl->getInterfaceType();
377-
if (auto *funcType = declType->getAs<AnyFunctionType>())
378-
candidates.emplace_back(funcType, decl);
376+
if (decl->hasInterfaceType())
377+
if (auto *funcType = decl->getInterfaceType()->getAs<AnyFunctionType>())
378+
candidates.emplace_back(funcType, decl);
379379
}
380380
} else if (auto *UDE = dyn_cast<UnresolvedDotExpr>(fnExpr)) {
381381
collectPossibleCalleesByQualifiedLookup(

0 commit comments

Comments
 (0)