From 0a380cbba3ff72bb7490970b7f2b1a19d505b928 Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Wed, 25 Jan 2023 13:49:27 -0500 Subject: [PATCH] Fix DeclarationMacro deprecations These deprecations are simple renames, but this PR should get rid of the warnings. --- lib/ASTGen/Sources/ASTGen/Macros.swift | 6 +++--- test/Macros/Inputs/syntax_macro_definitions.swift | 10 +++++----- test/Serialization/Inputs/def_macro_plugin.swift | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/ASTGen/Sources/ASTGen/Macros.swift b/lib/ASTGen/Sources/ASTGen/Macros.swift index 30d0bb6c8270a..4ffedc005ab73 100644 --- a/lib/ASTGen/Sources/ASTGen/Macros.swift +++ b/lib/ASTGen/Sources/ASTGen/Macros.swift @@ -177,7 +177,7 @@ func evaluateMacro( evaluatedSyntax = Syntax(try exprMacro.expansion(of: parentExpansion, in: &context)) // Handle expression macro. The resulting decls are wrapped in a `CodeBlockItemListSyntax`. - case let declMacro as FreestandingDeclarationMacro.Type: + case let declMacro as DeclarationMacro.Type: guard let parentExpansion = parentSyntax.as(MacroExpansionDeclSyntax.self) else { print("not on a macro expansion node: \(token.recursiveDescription)") return -1 @@ -321,7 +321,7 @@ func expandAttachedMacro( var evaluatedSyntaxStr: String do { switch (macro, macroRole) { - case (let attachedMacro as AccessorDeclarationMacro.Type, .Accessor): + case (let attachedMacro as AccessorMacro.Type, .Accessor): let accessors = try attachedMacro.expansion( of: customAttrNode, attachedTo: declarationNode, in: &context ) @@ -354,7 +354,7 @@ func expandAttachedMacro( $0.withoutTrivia().description }.joined(separator: " ") - case (let attachedMacro as MemberDeclarationMacro.Type, .SynthesizedMembers): + case (let attachedMacro as MemberMacro.Type, .SynthesizedMembers): let members = try attachedMacro.expansion( of: customAttrNode, attachedTo: declarationNode, diff --git a/test/Macros/Inputs/syntax_macro_definitions.swift b/test/Macros/Inputs/syntax_macro_definitions.swift index 65cd5e80cf467..4526c2edccbb5 100644 --- a/test/Macros/Inputs/syntax_macro_definitions.swift +++ b/test/Macros/Inputs/syntax_macro_definitions.swift @@ -192,7 +192,7 @@ enum CustomError: Error, CustomStringConvertible { } } -public struct DefineBitwidthNumberedStructsMacro: FreestandingDeclarationMacro { +public struct DefineBitwidthNumberedStructsMacro: DeclarationMacro { public static func expansion( of node: MacroExpansionDeclSyntax, in context: inout MacroExpansionContext @@ -215,7 +215,7 @@ public struct DefineBitwidthNumberedStructsMacro: FreestandingDeclarationMacro { public struct PropertyWrapperMacro {} -extension PropertyWrapperMacro: AccessorDeclarationMacro, Macro { +extension PropertyWrapperMacro: AccessorMacro, Macro { public static func expansion( of node: AttributeSyntax, attachedTo declaration: DeclSyntax, @@ -305,7 +305,7 @@ extension TypeWrapperMacro: MemberAttributeMacro { } } -extension TypeWrapperMacro: MemberDeclarationMacro { +extension TypeWrapperMacro: MemberMacro { public static func expansion( of node: AttributeSyntax, attachedTo decl: DeclSyntax, @@ -322,7 +322,7 @@ extension TypeWrapperMacro: MemberDeclarationMacro { } } -public struct AccessViaStorageMacro: AccessorDeclarationMacro { +public struct AccessViaStorageMacro: AccessorMacro { public static func expansion( of node: AttributeSyntax, attachedTo declaration: DeclSyntax, @@ -347,7 +347,7 @@ public struct AccessViaStorageMacro: AccessorDeclarationMacro { } } -public struct AddMembers: MemberDeclarationMacro { +public struct AddMembers: MemberMacro { public static func expansion( of node: AttributeSyntax, attachedTo decl: DeclSyntax, diff --git a/test/Serialization/Inputs/def_macro_plugin.swift b/test/Serialization/Inputs/def_macro_plugin.swift index 33623f5bccab8..6c9f17378599f 100644 --- a/test/Serialization/Inputs/def_macro_plugin.swift +++ b/test/Serialization/Inputs/def_macro_plugin.swift @@ -15,7 +15,7 @@ public struct StringifyMacro: ExpressionMacro { } } -public struct MyWrapperMacro: AccessorDeclarationMacro { +public struct MyWrapperMacro: AccessorMacro { public static func expansion( of node: AttributeSyntax, attachedTo declaration: DeclSyntax,