Skip to content

[5.10] Cherry-pick a couple of macro system fixes for attached accessor macros #2339

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 4 commits into from
Nov 13, 2023

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Nov 8, 2023

Cherry-pick #2187 and #2315 into release/5.10.

  • Explanation: Couple fixes to MacroSystem - one to allow returning an empty list of accessors for an attached accessor macro and another to remove initializers if a getter/setter is returned.
  • Risk: Low
  • Testing: New test cases
  • Issues: rdar://117442713
  • Reviewer: Alex Hoppen (@ahoppen)

If an accessor macro returns an empty array, MacroSystem was failing with internal error messages because it tried ot parse an `AccessorBlockSyntax` from an empty string.

To fix this, check if the expanded source is empty before trying to parse the `AccessorBlockSyntax`.

(cherry picked from commit 46c02e9)
@bnbarham bnbarham requested a review from ahoppen as a code owner November 8, 2023 01:24
@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 8, 2023

@swift-ci please test

@bnbarham bnbarham force-pushed the cherry-macro-system-fixes branch from af44f0e to 6e2476e Compare November 8, 2023 22:12
@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 8, 2023

@swift-ci please test

kimdv and others added 3 commits November 9, 2023 11:53
Postfix parsing should skip trailing closure if the base expression is
a literal (which is not callable).

(cherry picked from commit efbfbab)
SE-0389 specifies that a macro returning either a getter or setter
should remove the initializer, if one exists.

Resolves rdar://117442713 (swiftlang#2310)

(cherry picked from commit b3a3f1f)
@bnbarham bnbarham force-pushed the cherry-macro-system-fixes branch from 6e2476e to 418793a Compare November 9, 2023 19:58
@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 9, 2023

@swift-ci please test

@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 9, 2023

@swift-ci please test Windows platform

1 similar comment
@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 9, 2023

@swift-ci please test Windows platform

@ahoppen ahoppen merged commit 114c422 into swiftlang:release/5.10 Nov 13, 2023
@bnbarham bnbarham deleted the cherry-macro-system-fixes branch November 13, 2023 22:34
ahoppen added a commit that referenced this pull request Nov 29, 2023
[5.10] Cherry-pick multiple PRs to `release/5.10` 🚥 #2339
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants