File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Sources/SwiftSyntaxMacroExpansion
Tests/SwiftSyntaxMacroExpansionTest Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -320,10 +320,25 @@ private func expandExtensionMacro(
320
320
indentationWidth: Trivia
321
321
) throws -> CodeBlockItemListSyntax ? {
322
322
let extendedType : TypeSyntax
323
- if let identified = attachedTo. asProtocol ( NamedDeclSyntax . self) {
324
- extendedType = " \( identified. name. trimmed) "
325
- } else if let ext = attachedTo. as ( ExtensionDeclSyntax . self) {
323
+ if let ext = attachedTo. as ( ExtensionDeclSyntax . self) {
326
324
extendedType = " \( ext. extendedType. trimmed) "
325
+ } else if let identified = attachedTo. asProtocol ( NamedDeclSyntax . self) {
326
+ var types : [ TokenSyntax ] = [ ]
327
+ types. append ( identified. name. trimmed)
328
+
329
+ var possibleParent = attachedTo. parent
330
+ while let parent = possibleParent {
331
+ possibleParent = parent. parent
332
+ if let parent = parent. asProtocol ( NamedDeclSyntax . self) {
333
+ types. append ( parent. name. trimmed)
334
+ }
335
+ }
336
+
337
+ var baseType : TypeSyntax = TypeSyntax ( IdentifierTypeSyntax ( name: types. popLast ( ) !) )
338
+ for type in types. reversed ( ) {
339
+ baseType = TypeSyntax ( MemberTypeSyntax ( baseType: baseType, name: type) )
340
+ }
341
+ extendedType = baseType
327
342
} else {
328
343
return nil
329
344
}
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ final class ExtensionMacroTests: XCTestCase {
99
99
}
100
100
}
101
101
102
- extension MyType: Sendable {
102
+ extension Wrapper. MyType: Sendable {
103
103
}
104
104
""" ,
105
105
macros: [ " AddSendableExtension " : SendableExtensionMacro . self] ,
You can’t perform that action at this time.
0 commit comments