[NFC] Hide LoadedModules From Clients of ASTContext

There's no reason clients need to be able to access this data directly.
It obscures where module loading is actually happening, and makes it too
easy to accidentally register a module with the wrong identifier in the
context.

Hide the registration operations behind opaque accessors.
This commit is contained in:
Robert Widmann
2020-06-16 15:09:15 -07:00
parent 15c8c26301
commit 057097a6c3
10 changed files with 58 additions and 25 deletions

View File

@@ -959,7 +959,7 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
auto M = ModuleDecl::create(moduleID.Item, Ctx);
M->setIsSystemModule(isSystemModule);
Ctx.LoadedModules[moduleID.Item] = M;
Ctx.addLoadedModule(M);
SWIFT_DEFER { M->setHasResolvedImports(); };
StringRef moduleInterfacePathStr =
@@ -1010,7 +1010,7 @@ MemoryBufferSerializedModuleLoader::loadModule(SourceLoc importLoc,
return nullptr;
M->addFile(*file);
Ctx.LoadedModules[moduleID.Item] = M;
Ctx.addLoadedModule(M);
return M;
}