Skip to content

Commit 78209e2

Browse files
rintarorjmccall
authored andcommitted
[CodeCompletion] Fix a crash regression
1 parent 5417d28 commit 78209e2

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
@@ -404,21 +404,26 @@ static bool collectPossibleCalleesForApply(
404404

405405
if (auto *DRE = dyn_cast<DeclRefExpr>(fnExpr)) {
406406
if (auto *decl = DRE->getDecl()) {
407-
Type fnType = fnExpr->getType();
408-
if ((!fnType || fnType->hasError() || fnType->hasUnresolvedType()) &&
409-
decl->hasInterfaceType())
410-
fnType = decl->getInterfaceType();
411-
if (fnType) {
412-
fnType = fnType->getWithoutSpecifierType();
413-
if (auto *funcTy = fnType->getAs<AnyFunctionType>())
407+
Type declTy = fnExpr->getType();
408+
if ((!declTy || declTy->hasError() || declTy->hasUnresolvedType()) &&
409+
decl->hasInterfaceType()) {
410+
declTy = decl->getInterfaceType();
411+
declTy = decl->getInnermostDeclContext()->mapTypeIntoContext(declTy);
412+
}
413+
if (declTy) {
414+
declTy = declTy->getWithoutSpecifierType();
415+
if (auto *funcTy = declTy->getAs<AnyFunctionType>())
414416
candidates.emplace_back(funcTy, decl);
415417
}
416418
}
417419
} else if (auto *OSRE = dyn_cast<OverloadSetRefExpr>(fnExpr)) {
418420
for (auto *decl : OSRE->getDecls()) {
419-
if (decl->hasInterfaceType())
420-
if (auto *funcType = decl->getInterfaceType()->getAs<AnyFunctionType>())
421+
if (decl->hasInterfaceType()) {
422+
auto declTy = decl->getInterfaceType();
423+
declTy = decl->getInnermostDeclContext()->mapTypeIntoContext(declTy);
424+
if (auto *funcType = declTy->getAs<AnyFunctionType>())
421425
candidates.emplace_back(funcType, decl);
426+
}
422427
}
423428
} else if (auto *UDE = dyn_cast<UnresolvedDotExpr>(fnExpr)) {
424429
collectPossibleCalleesByQualifiedLookup(DC, UDE->getBase(), UDE->getName(),

0 commit comments

Comments
 (0)