mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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)
|
||||
]
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user