@@ -134,13 +134,13 @@ class MacroApplication<Context: MacroExpansionContext>: SyntaxRewriter {
134
134
do {
135
135
if let macro = macro as? CodeItemMacro . Type {
136
136
let expandedItemList = try macro. expansion (
137
- of: exprExpansion,
137
+ of: exprExpansion. detach ( in : context ) ,
138
138
in: context
139
139
)
140
140
newItems. append ( contentsOf: expandedItemList)
141
141
} else if let macro = macro as? DeclarationMacro . Type {
142
142
let expandedItemList = try macro. expansion (
143
- of: exprExpansion,
143
+ of: exprExpansion. detach ( in : context ) ,
144
144
in: context
145
145
)
146
146
newItems. append (
@@ -150,7 +150,7 @@ class MacroApplication<Context: MacroExpansionContext>: SyntaxRewriter {
150
150
)
151
151
} else if let macro = macro as? ExpressionMacro . Type {
152
152
let expandedExpr = try macro. expansion (
153
- of: exprExpansion,
153
+ of: exprExpansion. detach ( in : context ) ,
154
154
in: context
155
155
)
156
156
newItems. append ( CodeBlockItemSyntax ( item: . init( expandedExpr) ) )
@@ -190,7 +190,7 @@ class MacroApplication<Context: MacroExpansionContext>: SyntaxRewriter {
190
190
{
191
191
do {
192
192
let expandedList = try freestandingMacro. expansion (
193
- of: declExpansion,
193
+ of: declExpansion. detach ( in : context ) ,
194
194
in: context
195
195
)
196
196
@@ -297,8 +297,8 @@ class MacroApplication<Context: MacroExpansionContext>: SyntaxRewriter {
297
297
for (accessorAttr, accessorMacro) in accessorMacroAttributes {
298
298
do {
299
299
let newAccessors = try accessorMacro. expansion (
300
- of: accessorAttr,
301
- providingAccessorsOf: visitedNode,
300
+ of: accessorAttr. detach ( in : context ) ,
301
+ providingAccessorsOf: visitedNode. detach ( in : context ) ,
302
302
in: context
303
303
)
304
304
@@ -367,7 +367,11 @@ extension MacroApplication {
367
367
let macroAttributes = getMacroAttributes ( attachedTo: decl, ofType: PeerMacro . Type. self)
368
368
for (attribute, peerMacro) in macroAttributes {
369
369
do {
370
- let newPeers = try peerMacro. expansion ( of: attribute, providingPeersOf: decl, in: context)
370
+ let newPeers = try peerMacro. expansion (
371
+ of: attribute. detach ( in: context) ,
372
+ providingPeersOf: decl. detach ( in: context) ,
373
+ in: context
374
+ )
371
375
peers. append ( contentsOf: newPeers)
372
376
} catch {
373
377
context. addDiagnostics ( from: error, node: attribute)
@@ -388,8 +392,8 @@ extension MacroApplication {
388
392
do {
389
393
try newMembers. append (
390
394
contentsOf: memberMacro. expansion (
391
- of: attribute,
392
- providingMembersOf: decl,
395
+ of: attribute. detach ( in : context ) ,
396
+ providingMembersOf: decl. detach ( in : context ) ,
393
397
in: context
394
398
)
395
399
)
@@ -417,9 +421,9 @@ extension MacroApplication {
417
421
#if false
418
422
_openExistential ( decl) { d in
419
423
return try ! macro. expansion (
420
- of: attribute,
421
- attachedTo: d,
422
- annotating: member,
424
+ of: attribute. detach ( in : context ) ,
425
+ attachedTo: d. detach ( in : context ) ,
426
+ annotating: member. detach ( in : context ) ,
423
427
in: context
424
428
)
425
429
}
@@ -444,9 +448,9 @@ extension MacroApplication {
444
448
445
449
func expand< Decl: DeclGroupSyntax > ( _ decl: Decl ) throws -> [ AttributeSyntax ] {
446
450
return try attributeMacro. expansion (
447
- of: attribute,
448
- attachedTo: decl,
449
- providingAttributesFor: member. decl,
451
+ of: attribute. detach ( in : context ) ,
452
+ attachedTo: decl. detach ( in : context ) ,
453
+ providingAttributesFor: member. decl. detach ( in : context ) ,
450
454
in: context
451
455
)
452
456
}
0 commit comments