Skip to content

Commit c0bf473

Browse files
rintarorjmccall
authored andcommitted
[CodeCompletion] Fix a crash regression
1 parent 7407a80 commit c0bf473

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,21 +418,26 @@ static bool collectPossibleCalleesForApply(
418418

419419
if (auto *DRE = dyn_cast<DeclRefExpr>(fnExpr)) {
420420
if (auto *decl = DRE->getDecl()) {
421-
Type fnType = fnExpr->getType();
422-
if ((!fnType || fnType->hasError() || fnType->hasUnresolvedType()) &&
423-
decl->hasInterfaceType())
424-
fnType = decl->getInterfaceType();
425-
if (fnType) {
426-
fnType = fnType->getWithoutSpecifierType();
427-
if (auto *funcTy = fnType->getAs<AnyFunctionType>())
421+
Type declTy = fnExpr->getType();
422+
if ((!declTy || declTy->hasError() || declTy->hasUnresolvedType()) &&
423+
decl->hasInterfaceType()) {
424+
declTy = decl->getInterfaceType();
425+
declTy = decl->getInnermostDeclContext()->mapTypeIntoContext(declTy);
426+
}
427+
if (declTy) {
428+
declTy = declTy->getWithoutSpecifierType();
429+
if (auto *funcTy = declTy->getAs<AnyFunctionType>())
428430
candidates.emplace_back(funcTy, decl);
429431
}
430432
}
431433
} else if (auto *OSRE = dyn_cast<OverloadSetRefExpr>(fnExpr)) {
432434
for (auto *decl : OSRE->getDecls()) {
433-
if (decl->hasInterfaceType())
434-
if (auto *funcType = decl->getInterfaceType()->getAs<AnyFunctionType>())
435+
if (decl->hasInterfaceType()) {
436+
auto declTy = decl->getInterfaceType();
437+
declTy = decl->getInnermostDeclContext()->mapTypeIntoContext(declTy);
438+
if (auto *funcType = declTy->getAs<AnyFunctionType>())
435439
candidates.emplace_back(funcType, decl);
440+
}
436441
}
437442
} else if (auto *UDE = dyn_cast<UnresolvedDotExpr>(fnExpr)) {
438443
collectPossibleCalleesByQualifiedLookup(DC, UDE->getBase(), UDE->getName(),

0 commit comments

Comments
 (0)