[Serialization] Move some package-only import logic from writer to reader

Let's centralize the logic deciding if we load a transitive dependency
on the client side and have the producer write the truth in the
swiftmodule.
This commit is contained in:
Alexis Laferrière
2023-03-21 13:18:35 -07:00
parent e010d7d494
commit d7cd65cdd6
2 changed files with 5 additions and 2 deletions

View File

@@ -1694,6 +1694,8 @@ ModuleFileSharedCore::getTransitiveLoadingBehavior(
return ModuleLoadingBehavior::Required;
}
bool moduleIsResilient = getResilienceStrategy() ==
ResilienceStrategy::Resilient;
if (dependency.isImplementationOnly()) {
// Implementation-only dependencies are not usually loaded from
// transitive imports.
@@ -1712,7 +1714,8 @@ ModuleFileSharedCore::getTransitiveLoadingBehavior(
if (dependency.isPackageOnly()) {
// Package dependencies are usually loaded only for import from the same
// package.
if (!packageName.empty() && packageName == getModulePackageName()) {
if ((!packageName.empty() && packageName == getModulePackageName()) ||
!moduleIsResilient) {
return ModuleLoadingBehavior::Required;
} else if (debuggerMode) {
return ModuleLoadingBehavior::Optional;