[Serialization] Load non-public transitive dependencies on @testable imports

A @testable import allows a client to call internal decls which may
refer to non-public dependencies. To support such a use case, load
non-public transitive dependencies of a module when it's imported
@testable from the main module.

This replaces the previous behavior where we loaded those dependencies
for any modules built for testing. This was risky as we would load more
module for any debug build, opening the door to a different behavior
between debug and release builds. In contrast, applying this logic to
@testable clients will only change the behavior of test targets.

rdar://107329303
This commit is contained in:
Alexis Laferrière
2023-03-28 12:12:36 -07:00
parent 87431a7a66
commit f7f69c6ae1
9 changed files with 72 additions and 13 deletions

View File

@@ -614,11 +614,17 @@ public:
///
/// If \p packageName is set, transitive package dependencies are loaded if
/// loaded from the same package.
///
/// If \p forTestable, get the desired loading behavior for a @testable
/// import. Reports non-public dependencies as required for a testable
/// client so it can access internal details, which in turn can reference
/// those non-public dependencies.
ModuleLoadingBehavior
getTransitiveLoadingBehavior(const Dependency &dependency,
bool debuggerMode,
bool isPartialModule,
StringRef packageName) const;
StringRef packageName,
bool forTestable) const;
};
template <typename T, typename RawData>