[5.1 EARLY] [Frontend] Avoid doing whole-module work under primary-file typecheck #27159
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.
Same as #27158, but for the early cut 5.1 branch.
Explanation: Indexing logic in Xcode invokes
swiftc
in a way that just performs type-checking for a single file and then emits indexing data. However, the build invocation Xcode is using still implies the creation of auxiliary outputs that require whole-module knowledge, like module interface files. For now, avoid crashing on this by checking if we're not in a whole-module context and bailing out if so.Scope: Only affects invocations of
swiftc
that use-index-file
(and direct invocations of the compiler frontend, which is considered an unstable and unsupported interface for external tools).Issue: rdar://problem/53117124
Risk: Very low. This code path is not used for compilation.
Testing: Added a compiler regression test that previously produced the same crash signature as in the Radar.
Reviewed by: @akyrtzi