Introduce separately-imported stdlib overlays

The `_Concurrency` and `_StringProcessing` modules are implementation details of the standard library; to developers, their contents should behave as though they are declared directly within module `Swift`. This is the exact same behavior we expect of cross-import overlays, so treat these modules as though they are cross-import overlays with no bystanding module.

Because these modules don’t re-export the standard library, it’s also necessary to treat `Swift` as a separately imported overlay of itself; do so and make that actually work.
This commit is contained in:
Becca Royal-Gordon
2025-09-17 13:00:53 -07:00
parent 83629977da
commit 3abbfaa9cb
10 changed files with 93 additions and 27 deletions

View File

@@ -163,11 +163,18 @@ void ModuleNameLookup<LookupStrategy>::lookupInModule(
moduleOrFile->getParentModule(), overlays);
if (!overlays.empty()) {
// If so, look in each of those overlays.
for (auto overlay : overlays)
lookupInModule(decls, overlay, accessPath, moduleScopeContext, options);
bool selfOverlay = false;
for (auto overlay : overlays) {
if (overlay == moduleOrFile->getParentModule())
selfOverlay = true;
else
lookupInModule(decls, overlay, accessPath, moduleScopeContext,
options);
}
// FIXME: This may not work gracefully if more than one of these lookups
// finds something.
return;
if (!selfOverlay)
return;
}
const size_t initialCount = decls.size();