[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.
This commit is contained in:
Hamish Knight
2025-03-28 21:35:59 +00:00
parent c824be3052
commit bc5c8f51bd
2 changed files with 4 additions and 15 deletions

View File

@@ -41,10 +41,9 @@ public struct AddExtensionMacro: ExtensionMacro {
conformingTo protocols: [TypeSyntax],
in context: some MacroExpansionContext
) throws -> [ExtensionDeclSyntax] {
let typeName = declaration.declGroupName
return protocols.map {
("""
extension \(typeName): \($0) {
extension \(type.trimmed): \($0) {
struct _Extension_\($0): \($0) {
var nested = 8
}
@@ -53,8 +52,8 @@ public struct AddExtensionMacro: ExtensionMacro {
.cast(ExtensionDeclSyntax.self)
} + [
("""
extension \(typeName) {
static let _extension_\(typeName) = 3
extension \(type.trimmed) {
static let _extension_\(declaration.declGroupName) = 3
}
""" as DeclSyntax).cast(ExtensionDeclSyntax.self)
]

View File

@@ -40,10 +40,9 @@ public struct AddExtensionMacro: ExtensionMacro {
conformingTo protocols: [TypeSyntax],
in context: some MacroExpansionContext
) throws -> [ExtensionDeclSyntax] {
let typeName = declaration.declGroupName
return protocols.map {
("""
extension \(typeName): \($0) {
extension \(type.trimmed): \($0) {
struct _Extension_\($0): \($0) {}
}
""" as DeclSyntax)
@@ -66,12 +65,3 @@ extension DeclSyntaxProtocol {
fatalError("Not implemented")
}
}
extension DeclGroupSyntax {
var declGroupName: TokenSyntax {
if let structDecl = self.as(StructDeclSyntax.self) {
return structDecl.name.trimmed
}
fatalError("Not implemented")
}
}