Currently it errors when loading a module built from interface if it has package-name.

This disallows building an interface file that imports such module which should be allowed
since interface does not contain package symbols unless usableFromInline or inlinable.
This change limits erroring only when building a .swift file.

Resolves rdar://108633068
This commit is contained in:
Ellie Shin
2023-04-27 16:01:03 -07:00
parent 347e565599
commit ceb2884183
3 changed files with 173 additions and 10 deletions

View File

@@ -804,15 +804,6 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
if (loadedModuleFile->isConcurrencyChecked())
M.setIsConcurrencyChecked();
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());