Simplify swift_common.compile
so that it returns a SwiftInfo
that can be propagated by callers
#1370
+43
−27
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.
The impetus for this change was the fact that inferred cross-import overlay providers weren't being merged into the propagated
SwiftInfo
, so compiling a target that directly depended on one would succeed but compiling something depending on that other target would fail.Since provider merging was being done by the rules, not by the
compile
call that collected the providers, we would have had to offer a separate API for rule implementations to collect those same cross-import providers or havecompile
return them in some separate fashion.However, all current callers of
swift_common.compile
are doing exactly the same thing: creating a newSwiftInfo
that merges the returned module context with the depsSwiftInfo
s that it already collected and passed tocompile
. So, it's straightforward to just return thatSwiftInfo
, into which we can merge the cross-import providers. This ensures we don't drop anything on the floor and it's a major API improvement.PiperOrigin-RevId: 500710468
(cherry picked from commit ac4375d)