Skip to content

[5.9][Macros] Ability to opt-out from auto-propagation of attrs/modifiers #1739

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jun 7, 2023

Cherry-pick #1738 into release/5.9

  • Explanation: By default, attributes/modifiers on macro expansion syntax are copied/propagated to expanded declarations. But there're cases that behavior is not desirable. Add ability to DeclarationMacro opting-out from it, and handle attributes/modifiers themselves.
  • Scope: Freestanding macro expansion
  • Risk: Low, this doesn't affect existing macro implementations
  • Testing: Added regression test cases.
  • Issue: rdar://110364154
  • Reviewer: Alex Hoppen (@ahoppen) Doug Gregor (@DougGregor)

`DeclarationMacro` now have two optional requirements that is defaulted
to 'true':

  static var propagateFreestandingMacroAttributes: Bool { get }
  static var propagateFreestandingMacroModifiers: Bool { get }

My implementing these and returning 'false', macro expansion systam
won't copy attributes and/or modifiers to the expanded declarations.

rdar://110364154
(cherry picked from commit dc4b08c)
@rintaro
Copy link
Member Author

rintaro commented Jun 7, 2023

@swift-ci Please test

@rintaro rintaro changed the title [Macros] Ability to opt-out from auto-propagation of attrs/modifiers [5.9][Macros] Ability to opt-out from auto-propagation of attrs/modifiers Jun 7, 2023
@rintaro
Copy link
Member Author

rintaro commented Jun 7, 2023

@swift-ci Please test Windows

@DougGregor
Copy link
Member

@swift-ci please test Windows

1 similar comment
@rintaro
Copy link
Member Author

rintaro commented Jun 7, 2023

@swift-ci please test Windows

@shahmishal shahmishal merged commit dd22ee8 into swiftlang:release/5.9 Jun 7, 2023
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.

4 participants