File tree Expand file tree Collapse file tree 3 files changed +21
-12
lines changed
Sources/_SwiftSyntaxMacros
Tests/SwiftSyntaxMacrosTest Expand file tree Collapse file tree 3 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,13 @@ public protocol MemberMacro: AttachedMacro {
23
23
///
24
24
/// - Returns: the set of member declarations introduced by this macro, which
25
25
/// are nested inside the `attachedTo` declaration.
26
- static func expansion(
26
+ static func expansion<
27
+ Declaration: DeclGroupSyntax ,
28
+ Context: MacroExpansionContext
29
+ > (
27
30
of node: AttributeSyntax ,
28
- attachedTo declaration: DeclSyntax ,
29
- in context: any MacroExpansionContext
31
+ attachedTo declaration: Declaration ,
32
+ in context: Context
30
33
) throws -> [ DeclSyntax ]
31
34
}
32
35
Original file line number Diff line number Diff line change @@ -401,7 +401,7 @@ extension MacroApplication {
401
401
try newMembers. append (
402
402
contentsOf: memberMacro. expansion (
403
403
of: attribute,
404
- attachedTo: DeclSyntax ( decl) ,
404
+ attachedTo: decl,
405
405
in: context
406
406
)
407
407
)
@@ -495,9 +495,9 @@ extension MacroApplication {
495
495
extension SyntaxProtocol {
496
496
/// Expand all uses of the given set of macros within this syntax
497
497
/// node.
498
- public func expand(
498
+ public func expand< Context : MacroExpansionContext > (
499
499
macros: [ String : Macro . Type ] ,
500
- in context: any MacroExpansionContext
500
+ in context: Context
501
501
) -> Syntax {
502
502
// Build the macro system.
503
503
var system = MacroSystem ( )
Original file line number Diff line number Diff line change @@ -440,10 +440,13 @@ public struct AddCompletionHandler: PeerMacro {
440
440
}
441
441
442
442
public struct AddBackingStorage : MemberMacro {
443
- public static func expansion(
443
+ public static func expansion<
444
+ Declaration: DeclGroupSyntax ,
445
+ Context: MacroExpansionContext
446
+ > (
444
447
of node: AttributeSyntax ,
445
- attachedTo decl: DeclSyntax ,
446
- in context: any MacroExpansionContext
448
+ attachedTo decl: Declaration ,
449
+ in context: Context
447
450
)
448
451
throws -> [ DeclSyntax ]
449
452
{
@@ -527,10 +530,13 @@ public struct WrapStoredProperties: MemberAttributeMacro {
527
530
struct CustomTypeWrapperMacro { }
528
531
529
532
extension CustomTypeWrapperMacro : MemberMacro {
530
- static func expansion(
533
+ static func expansion<
534
+ Declaration: DeclGroupSyntax ,
535
+ Context: MacroExpansionContext
536
+ > (
531
537
of node: AttributeSyntax ,
532
- attachedTo declaration: DeclSyntax ,
533
- in context: any MacroExpansionContext
538
+ attachedTo declaration: Declaration ,
539
+ in context: Context
534
540
) throws -> [ DeclSyntax ] {
535
541
return [
536
542
"""
You can’t perform that action at this time.
0 commit comments