Skip to content

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

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jun 7, 2023

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

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

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

rdar://110364154

I will add a test case with actual plugins in swift repo.

`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
@rintaro
Copy link
Member Author

rintaro commented Jun 7, 2023

@swift-ci Please test

Comment on lines +24 to +25
/// Whether to copy attributes on the expansion syntax to expanded declarations,
/// 'true' by default.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an example would illustrate the point really well here.

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

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