@@ -1763,7 +1763,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
1763
1763
}
1764
1764
1765
1765
void addModuleName (
1766
- const ModuleDecl *MD,
1766
+ ModuleDecl *MD,
1767
1767
Optional<CodeCompletionResult::NotRecommendedReason> R = None) {
1768
1768
1769
1769
// Don't add underscored cross-import overlay modules.
@@ -3293,16 +3293,29 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3293
3293
bool tryModuleCompletions (Type ExprType, bool TypesOnly = false ) {
3294
3294
if (auto MT = ExprType->getAs <ModuleType>()) {
3295
3295
ModuleDecl *M = MT->getModule ();
3296
- if (CurrModule != M) {
3297
- // Only use the cache if it is not the current module.
3296
+
3297
+ // Only lookup this module's symbols from the cache if it is not the
3298
+ // current module.
3299
+ if (M == CurrModule)
3300
+ return false ;
3301
+
3302
+ // If the module is shadowed by a separately imported overlay(s), look up
3303
+ // the symbols from the overlay(s) instead.
3304
+ SmallVector<ModuleDecl *, 1 > ShadowingOrOriginal;
3305
+ if (auto *SF = CurrDeclContext->getParentSourceFile ()) {
3306
+ SF->getSeparatelyImportedOverlays (M, ShadowingOrOriginal);
3307
+ if (ShadowingOrOriginal.empty ())
3308
+ ShadowingOrOriginal.push_back (M);
3309
+ }
3310
+ for (ModuleDecl *M: ShadowingOrOriginal) {
3298
3311
RequestedResultsTy Request = RequestedResultsTy::fromModule (M)
3299
3312
.needLeadingDot (needDot ())
3300
3313
.withModuleQualifier (false );
3301
3314
if (TypesOnly)
3302
3315
Request = Request.onlyTypes ();
3303
3316
RequestedCachedResults.push_back (Request);
3304
- return true ;
3305
3317
}
3318
+ return true ;
3306
3319
}
3307
3320
return false ;
3308
3321
}
0 commit comments