swift-memberwise-init-macro
swift-memberwise-init-macro copied to clipboard
Give `MemberwiseInit` support for `@inlinable` and `@usableFromInline`
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.
- 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?
- 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
.asare 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