@@ -418,21 +418,26 @@ static bool collectPossibleCalleesForApply(
418
418
419
419
if (auto *DRE = dyn_cast<DeclRefExpr>(fnExpr)) {
420
420
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>())
428
430
candidates.emplace_back (funcTy, decl);
429
431
}
430
432
}
431
433
} else if (auto *OSRE = dyn_cast<OverloadSetRefExpr>(fnExpr)) {
432
434
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>())
435
439
candidates.emplace_back (funcType, decl);
440
+ }
436
441
}
437
442
} else if (auto *UDE = dyn_cast<UnresolvedDotExpr>(fnExpr)) {
438
443
collectPossibleCalleesByQualifiedLookup (DC, UDE->getBase (), UDE->getName (),
0 commit comments