There is also an open question in the implementation that may have public API impacts: Add support for body macros on variables and accessors by calda · Pull Request #3298 · swiftlang/swift-syntax · GitHub
The existing signature of BodyMacro.expansion is:
static func expansion(
of node: AttributeSyntax,
providingBodyFor declaration: some DeclSyntaxProtocol & WithOptionalCodeBlockSyntax,
in context: some MacroExpansionContext
) throws -> [CodeBlockItemSyntax]
This works for get / set accessors (AccessorDeclSyntax, conforms to WithOptionalCodeBlockSyntax) but doesn’t work out of the box for properties without explicit accessors (VariableDeclSyntax doesn’t conform to WithOptionalCodeBlockSyntax).
Should we introduce a new expansion signature for computed properties without accessors?
static func expansion(
of node: AttributeSyntax,
providingBodyFor declaration: VariableDeclSyntax, // new
in context: some MacroExpansionContext
) throws -> [CodeBlockItemSyntax]
Or, should we make this work through the existing WithOptionalCodeBlockSyntax signature (implementation options discussion here)?
If we prefer a new signature, this seems like it would need to be ran as an amendment to SE-0415. Would love a suggestion from the LSG on the direction here.