Skip to content

Commit 64e7475

Browse files
authored
Merge pull request #2009 from hborla/remove-conformance-macro-protocol
[Macros] Remove the `ConformanceMacro` protocol.
2 parents e340af4 + 125ed90 commit 64e7475

File tree

4 files changed

+7
-122
lines changed

4 files changed

+7
-122
lines changed

Examples/Sources/ExamplePlugin/Macros.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,16 @@ struct MemberDeprecatedMacro: MemberAttributeMacro {
7676
}
7777

7878
/// Add 'Equatable' conformance.
79-
struct EquatableConformanceMacro: ConformanceMacro {
79+
struct EquatableConformanceMacro: ExtensionMacro {
8080
static func expansion(
8181
of node: AttributeSyntax,
82-
providingConformancesOf declaration: some DeclGroupSyntax,
82+
attachedTo declaration: some DeclGroupSyntax,
83+
providingExtensionsOf type: some TypeSyntaxProtocol,
84+
conformingTo protocols: [TypeSyntax],
8385
in context: some MacroExpansionContext
84-
) throws -> [(TypeSyntax, GenericWhereClauseSyntax?)] {
85-
return [("Equatable", nil)]
86+
) throws -> [ExtensionDeclSyntax] {
87+
let ext: DeclSyntax = "extension \(type.trimmed): Equatable {}"
88+
return [ext.cast(ExtensionDeclSyntax.self)]
8689
}
8790
}
8891

Sources/SwiftSyntaxMacros/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ add_swift_host_library(SwiftSyntaxMacros
1010
MacroProtocols/AccessorMacro.swift
1111
MacroProtocols/AttachedMacro.swift
1212
MacroProtocols/CodeItemMacro.swift
13-
MacroProtocols/ConformanceMacro.swift
1413
MacroProtocols/DeclarationMacro.swift
1514
MacroProtocols/ExpressionMacro.swift
1615
MacroProtocols/ExtensionMacro.swift

Sources/SwiftSyntaxMacros/MacroProtocols/ConformanceMacro.swift

Lines changed: 0 additions & 68 deletions
This file was deleted.

Tests/SwiftSyntaxMacroExpansionTest/MacroSystemTests.swift

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -642,16 +642,6 @@ public struct DeclsFromStringsMacro: DeclarationMacro, MemberMacro {
642642
}
643643
}
644644

645-
public struct SendableConformanceMacro: ConformanceMacro {
646-
public static func expansion(
647-
of node: AttributeSyntax,
648-
providingConformancesOf declaration: some DeclGroupSyntax,
649-
in context: some MacroExpansionContext
650-
) throws -> [(TypeSyntax, GenericWhereClauseSyntax?)] {
651-
return [("Sendable", nil)]
652-
}
653-
}
654-
655645
public struct SendableExtensionMacro: ExtensionMacro {
656646
public static func expansion(
657647
of node: AttributeSyntax,
@@ -717,7 +707,6 @@ public let testMacros: [String: Macro.Type] = [
717707
"wrapStoredProperties": WrapStoredProperties.self,
718708
"customTypeWrapper": CustomTypeWrapperMacro.self,
719709
"unwrap": UnwrapMacro.self,
720-
"AddSendable": SendableConformanceMacro.self,
721710
"AddSendableExtension": SendableExtensionMacro.self,
722711
]
723712

@@ -1537,44 +1526,6 @@ final class MacroSystemTests: XCTestCase {
15371526
)
15381527
}
15391528

1540-
func testConformanceExpansion() {
1541-
assertMacroExpansion(
1542-
"""
1543-
@AddSendable
1544-
struct MyType {
1545-
}
1546-
""",
1547-
expandedSource: """
1548-
1549-
struct MyType {
1550-
}
1551-
1552-
extension MyType: Sendable {
1553-
}
1554-
""",
1555-
macros: testMacros,
1556-
indentationWidth: indentationWidth
1557-
)
1558-
1559-
assertMacroExpansion(
1560-
"""
1561-
@AddSendable
1562-
extension A.B {
1563-
}
1564-
""",
1565-
expandedSource: """
1566-
1567-
extension A.B {
1568-
}
1569-
1570-
extension A.B: Sendable {
1571-
}
1572-
""",
1573-
macros: testMacros,
1574-
indentationWidth: indentationWidth
1575-
)
1576-
}
1577-
15781529
func testExtensionExpansion() {
15791530
assertMacroExpansion(
15801531
"""

0 commit comments

Comments
 (0)