Skip to content

Commit 1b834a0

Browse files
committed
Update freestanding macro protocols to use generics
1 parent 35ad12c commit 1b834a0

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Sources/_SwiftSyntaxMacros/MacroProtocols/CodeItemMacro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import SwiftSyntax
1313
public protocol CodeItemMacro: FreestandingMacro {
1414
/// Expand a macro described by the given freestanding macro expansion
1515
/// declaration within the given context to produce a set of declarations.
16-
static func expansion(
16+
static func expansion<Context: MacroExpansionContext>(
1717
of node: MacroExpansionDeclSyntax,
18-
in context: any MacroExpansionContext
18+
in context: Context
1919
) throws -> [CodeBlockItemSyntax]
2020
}

Sources/_SwiftSyntaxMacros/MacroProtocols/DeclarationMacro.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import SwiftSyntax
1313
public protocol DeclarationMacro: FreestandingMacro {
1414
/// Expand a macro described by the given freestanding macro expansion
1515
/// declaration within the given context to produce a set of declarations.
16-
static func expansion(
16+
static func expansion<
17+
Context: MacroExpansionContext
18+
>(
1719
of node: MacroExpansionDeclSyntax,
18-
in context: any MacroExpansionContext
20+
in context: Context
1921
) throws -> [DeclSyntax]
2022
}
2123

Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ extension SimpleDiagnosticMessage: FixItMessage {
198198
}
199199

200200
public struct ErrorMacro: DeclarationMacro {
201-
public static func expansion(
201+
public static func expansion<Context: MacroExpansionContext>(
202202
of node: MacroExpansionDeclSyntax,
203-
in context: any MacroExpansionContext
203+
in context: Context
204204
) throws -> [DeclSyntax] {
205205
guard let firstElement = node.argumentList.first,
206206
let stringLiteral = firstElement.expression
@@ -227,9 +227,9 @@ public struct ErrorMacro: DeclarationMacro {
227227
}
228228

229229
struct DefineBitwidthNumberedStructsMacro: DeclarationMacro {
230-
static func expansion(
230+
static func expansion<Context: MacroExpansionContext>(
231231
of node: MacroExpansionDeclSyntax,
232-
in context: any MacroExpansionContext
232+
in context: Context
233233
) throws -> [DeclSyntax] {
234234
guard let firstElement = node.argumentList.first,
235235
let stringLiteral = firstElement.expression

0 commit comments

Comments
 (0)