[Serialization] Attempt to load transitive impl-only dependencies on testable imports

Implementation-only dependencies may be referenced from internal decls.
When that module is imported as @testable, clients see the internal
decls and may fail accessing them if the transitive implementation-only
dependencies are not loaded.

Let's consider such transtive implementation-only dependencies as
optional for @testable imports. As such, the compiler will attempt to
load them for test targets, and won't fail if the dependency is missing.

We can make these dependencies required for non-public imports, but it
could be project breaking to do so for implementation-only dependencies.
Considering them as optional is a decent compromise.

rdar://79459263
This commit is contained in:
Alexis Laferrière
2023-03-15 22:24:13 -07:00
parent b4e296988a
commit 4327c7342f
2 changed files with 62 additions and 1 deletions

View File

@@ -1702,7 +1702,7 @@ ModuleFileSharedCore::getTransitiveLoadingBehavior(
if (dependency.isImplementationOnly()) {
// Implementation-only dependencies are not usually loaded from
// transitive imports.
if (debuggerMode) {
if (debuggerMode || forTestable) {
// In the debugger, try to load the module if possible.
// Same in the case of a testable import, try to load the dependency
// but don't fail if it's missing as this could be source breaking.