Skip to content

[6.0] [Sema] Don't parse skipped bodies when computing discriminators #75423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Jul 23, 2024

6.0 cherry-pick of #75421

  • Explanation: Fixes an issue where #sourceLocation() would incorrectly be diagnosed with an error in a function body when emitting a module. More generally, this change also stops us from needlessly parsing function bodies when emitting modules.
  • Scope: Affects compilation when function body skipping is enabled, e.g when emitting modules
  • Issue: rdar://131726797, sourceLocation error in Swift 6 (but not Swift 5 or with slight modification) #74561
  • Risk: Low, the fix is minimal, and restores the behavior that is already present in Xcode 16b3
  • Testing: Added tests to test suite
  • Reviewer: Allan Shortlidge

The refactoring in swiftlang#68760 accidentally caused us to
start parsing skipped function bodies if they have
parameters, as the local discriminator request kicks
parsing through `getBody()`. Cherry-pick part of
47ff956 which was
never landed, ensuring we don't call `getBody` for
a skipped function body.

This is meant to be a minimal low-risk change that
fixes the issue in question, restoring the behavior
we had in 5.10. Fixing the parser skipping
behavior for `#sourceLocation` will be done in
a follow-up. We also ought to see if there's a
better way we can enforce that skipped function
bodies don't end up getting parsed, for now I've
added a test.

rdar://131726797
@hamishknight hamishknight added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.0 labels Jul 23, 2024
@hamishknight hamishknight requested a review from bnbarham July 23, 2024 20:46
@hamishknight hamishknight requested a review from a team as a code owner July 23, 2024 20:46
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit e755f6e into swiftlang:release/6.0 Jul 24, 2024
5 checks passed
@hamishknight hamishknight deleted the skip-6.0 branch July 24, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants