Skip to content

Give MemberwiseInit support for @inlinable and @usableFromInline #49

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

plx
Copy link

@plx plx commented May 2, 2025

Hi, thanks for making this macro—it solves a recurring problem really thoroughly!

This PR attempts to give MemberwiseInit the ability to synthesize initializers that are either @usableFromInline or @inlinable. This is somewhat of a niche requirement, but if you're writing code that uses those attributes then you often need to hand-write the memberwise init just to get the attribute applied.

Assuming you're open to incorporating this capability into the package, I had a couple questions.

  1. Unit Testing: right now I've hand-verified the macros and fix-its appear to behave as-expected, but haven't setup any formal unit tests yet. Before adding unit tests, I wanted to know if (a) you'd be ok with a smaller number of hand-written checks or (b) you'd need to see something comparable-to/integrated-with your existing test-code-generation strategy?
  2. API Design: I tried to make the changes fit in with the existing style and stay readable at the use site. Let me know if you'd like anything changed.

Other remarks:

  • I addressed some deprecation warnings (e.g. some uses of .as are now deprecated)
  • I added some helper functions to reduce boilerplate
  • I ran swift-format once on the Diagnostics.swift file and it changed some existing code I didn't touch—happy to back that out

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.

1 participant