@@ -404,21 +404,26 @@ static bool collectPossibleCalleesForApply(
404
404
405
405
if (auto *DRE = dyn_cast<DeclRefExpr>(fnExpr)) {
406
406
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>())
414
416
candidates.emplace_back (funcTy, decl);
415
417
}
416
418
}
417
419
} else if (auto *OSRE = dyn_cast<OverloadSetRefExpr>(fnExpr)) {
418
420
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>())
421
425
candidates.emplace_back (funcType, decl);
426
+ }
422
427
}
423
428
} else if (auto *UDE = dyn_cast<UnresolvedDotExpr>(fnExpr)) {
424
429
collectPossibleCalleesByQualifiedLookup (DC, UDE->getBase (), UDE->getName (),
0 commit comments