Enable cross-import overlays in test targets. #8158
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enables cross-import overlays when building test targets. Swift Testing cannot link to most modules because it would/could introduce circular dependencies that prevent those modules from being tested using Swift Testing. However, we need to introduce some API that uses types from Foundation and other modules, which means we need to use the cross-import overlays feature supported by the compiler.
Cross-import overlays haven't been through Swift Evolution, so we don't want to enable the feature in the general case. We talked with @beccadax who agreed that because our use case is relatively unique, enabling these overlays just for test targets was probably the right approach until/unless the feature can be fully reviewed and supported.
We're also looking at consulting available information (the dependency scanner) to determine if there is any dependency on Swift Testing. If there isn't one, we don't need this flag. That's a "future direction" for this PR at any rate.