Skip to content

Commit bc5c8f5

Browse files
committed
[test] Fix extension macros in test suite
Make sure we're using `providingExtensionsOf` as the extended type, previously we were just using the unqualified name of the decl.
1 parent c824be3 commit bc5c8f5

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

test/ConstExtraction/Inputs/Macros.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ public struct AddExtensionMacro: ExtensionMacro {
4141
conformingTo protocols: [TypeSyntax],
4242
in context: some MacroExpansionContext
4343
) throws -> [ExtensionDeclSyntax] {
44-
let typeName = declaration.declGroupName
4544
return protocols.map {
4645
("""
47-
extension \(typeName): \($0) {
46+
extension \(type.trimmed): \($0) {
4847
struct _Extension_\($0): \($0) {
4948
var nested = 8
5049
}
@@ -53,8 +52,8 @@ public struct AddExtensionMacro: ExtensionMacro {
5352
.cast(ExtensionDeclSyntax.self)
5453
} + [
5554
("""
56-
extension \(typeName) {
57-
static let _extension_\(typeName) = 3
55+
extension \(type.trimmed) {
56+
static let _extension_\(declaration.declGroupName) = 3
5857
}
5958
""" as DeclSyntax).cast(ExtensionDeclSyntax.self)
6059
]

test/Reflection/Inputs/Macros.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ public struct AddExtensionMacro: ExtensionMacro {
4040
conformingTo protocols: [TypeSyntax],
4141
in context: some MacroExpansionContext
4242
) throws -> [ExtensionDeclSyntax] {
43-
let typeName = declaration.declGroupName
4443
return protocols.map {
4544
("""
46-
extension \(typeName): \($0) {
45+
extension \(type.trimmed): \($0) {
4746
struct _Extension_\($0): \($0) {}
4847
}
4948
""" as DeclSyntax)
@@ -66,12 +65,3 @@ extension DeclSyntaxProtocol {
6665
fatalError("Not implemented")
6766
}
6867
}
69-
70-
extension DeclGroupSyntax {
71-
var declGroupName: TokenSyntax {
72-
if let structDecl = self.as(StructDeclSyntax.self) {
73-
return structDecl.name.trimmed
74-
}
75-
fatalError("Not implemented")
76-
}
77-
}

0 commit comments

Comments
 (0)