Merge pull request #64488 from apple/es-load

Do not load modules of the same package if built from interface
This commit is contained in:
Ellie Shin
2023-03-22 23:26:12 -07:00
committed by GitHub
3 changed files with 56 additions and 1 deletions

View File

@@ -802,8 +802,18 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
M.setABIName(Ctx.getIdentifier(loadedModuleFile->getModuleABIName()));
if (loadedModuleFile->isConcurrencyChecked())
M.setIsConcurrencyChecked();
if (!loadedModuleFile->getModulePackageName().empty())
if (!loadedModuleFile->getModulePackageName().empty()) {
if (loadedModuleFile->isBuiltFromInterface() &&
loadedModuleFile->getModulePackageName().str() == Ctx.LangOpts.PackageName) {
Ctx.Diags.diagnose(SourceLoc(),
diag::in_package_module_not_compiled_from_source,
M.getBaseIdentifier(),
Ctx.LangOpts.PackageName,
loadedModuleFile->getModuleSourceFilename()
);
}
M.setPackageName(Ctx.getIdentifier(loadedModuleFile->getModulePackageName()));
}
M.setUserModuleVersion(loadedModuleFile->getUserModuleVersion());
for (auto name: loadedModuleFile->getAllowableClientNames()) {
M.addAllowableClientName(Ctx.getIdentifier(name));