@@ -23,9 +23,54 @@ public protocol MemberMacro: AttachedMacro {
2323 ///
2424 /// - Returns: the set of member declarations introduced by this macro, which
2525 /// are nested inside the `attachedTo` declaration.
26+ @available ( * , deprecated, message: " Use expansion(of:providingMembersOf:conformingTo:in: " )
2627 static func expansion(
2728 of node: AttributeSyntax ,
2829 providingMembersOf declaration: some DeclGroupSyntax ,
2930 in context: some MacroExpansionContext
3031 ) throws -> [ DeclSyntax ]
32+
33+ /// Expand an attached declaration macro to produce a set of members.
34+ ///
35+ /// - Parameters:
36+ /// - node: The custom attribute describing the attached macro.
37+ /// - declaration: The declaration the macro attribute is attached to.
38+ /// - conformingTo: The set of protocols that were declared
39+ /// in the set of conformances for the macro and to which the declaration
40+ /// does not explicitly conform. The member macro itself cannot declare
41+ /// conformances to these protocols (only an extension macro can do that),
42+ /// but can provide supporting declarations, such as a required
43+ /// initializer or stored property, that cannot be written in an
44+ /// extension.
45+ /// - context: The context in which to perform the macro expansion.
46+ ///
47+ /// - Returns: the set of member declarations introduced by this macro, which
48+ /// are nested inside the `attachedTo` declaration.
49+ static func expansion(
50+ of node: AttributeSyntax ,
51+ providingMembersOf declaration: some DeclGroupSyntax ,
52+ conformingTo protocols: [ TypeSyntax ] ,
53+ in context: some MacroExpansionContext
54+ ) throws -> [ DeclSyntax ]
55+ }
56+
57+ public extension MemberMacro {
58+ /// Default implementation supplies no conformances.
59+ static func expansion(
60+ of node: AttributeSyntax ,
61+ providingMembersOf declaration: some DeclGroupSyntax ,
62+ in context: some MacroExpansionContext
63+ ) throws -> [ DeclSyntax ] {
64+ return try expansion ( of: node, providingMembersOf: declaration, conformingTo: [ ] , in: context)
65+ }
66+
67+ /// Default implementation that ignores the unhandled conformances.
68+ static func expansion(
69+ of node: AttributeSyntax ,
70+ providingMembersOf declaration: some DeclGroupSyntax ,
71+ conformingTo protocols: [ TypeSyntax ] ,
72+ in context: some MacroExpansionContext
73+ ) throws -> [ DeclSyntax ] {
74+ return try expansion ( of: node, providingMembersOf: declaration, in: context)
75+ }
3176}
0 commit comments