Skip to content

Commit b485187

Browse files
committed
Change function signatures of expansion functions of macros to be synchronous
The different macro proposals have been inconsistent about whether the expansion function should be synchronous or asynchronous. - Synchronous - SE-0415 Function Body Macros - SE-0402 Extension Macros - SE-0407 Member Macro Conformances - SE-0397 Freestanding Declaration Macros (but future directions uses `async` function) - Async - SE-0389 Attached Macros - SE-0382 Expression Macros swift-syntax has always implemented synchronous expansion functions. Update the proposals to consistently use synchronous expansion functions to reflect that.
1 parent 2c10ffe commit b485187

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

proposals/0382-expression-macros.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public protocol ExpressionMacro: FreestandingMacro {
9292
static func expansion(
9393
of node: some FreestandingMacroExpansionSyntax,
9494
in context: some MacroExpansionContext
95-
) async throws -> ExprSyntax
95+
) throws -> ExprSyntax
9696
}
9797
```
9898

@@ -250,7 +250,7 @@ public protocol ExpressionMacro: FreestandingMacro {
250250
static func expansion(
251251
of node: some FreestandingMacroExpansionSyntax,
252252
in context: some MacroExpansionContext
253-
) async throws -> ExprSyntax
253+
) throws -> ExprSyntax
254254
}
255255
```
256256

@@ -567,6 +567,8 @@ Expressions are just one place in the language where macros could be valuable. O
567567

568568
## Revision History
569569

570+
* Revision after acceptance:
571+
* Make the `ExpressionMacro.expansion(of:in:)` requirement non-`async`.
570572
* Revisions based on review feedback:
571573
* Switch `@expression` to `@freestanding(expression)` to align with the other macros proposals and vision document.
572574
* Make the `ExpressionMacro.expansion(of:in:)` requirement `async`.

proposals/0389-attached-macros.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public PeerMacro: AttachedMacro {
7171
of node: AttributeSyntax,
7272
providingPeersOf declaration: some DeclSyntaxProtocol,
7373
in context: some MacroExpansionContext
74-
) async throws -> [DeclSyntax]
74+
) throws -> [DeclSyntax]
7575
}
7676
```
7777

@@ -163,7 +163,7 @@ protocol MemberMacro: AttachedMacro {
163163
of node: AttributeSyntax,
164164
providingMembersOf declaration: some DeclGroupSyntax,
165165
in context: some MacroExpansionContext
166-
) async throws -> [DeclSyntax]
166+
) throws -> [DeclSyntax]
167167
}
168168
```
169169

@@ -232,7 +232,7 @@ protocol AccessorMacro: AttachedMacro {
232232
of node: AttributeSyntax,
233233
providingAccessorsOf declaration: some DeclSyntaxProtocol,
234234
in context: some MacroExpansionContext
235-
) async throws -> [AccessorDeclSyntax]
235+
) throws -> [AccessorDeclSyntax]
236236
}
237237
```
238238

@@ -294,7 +294,7 @@ protocol MemberAttributeMacro: AttachedMacro {
294294
attachedTo declaration: some DeclGroupSyntax,
295295
providingAttributesOf member: some DeclSyntaxProtocol,
296296
in context: some MacroExpansionContext
297-
) async throws -> [AttributeSyntax]
297+
) throws -> [AttributeSyntax]
298298
}
299299
```
300300

proposals/0397-freestanding-declaration-macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public protocol CodeItemMacro: FreestandingMacro {
323323
static func expansion(
324324
of node: some FreestandingMacroExpansionSyntax,
325325
in context: some MacroExpansionContext
326-
) async throws -> [CodeBlockItemSyntax]
326+
) throws -> [CodeBlockItemSyntax]
327327
}
328328
```
329329

0 commit comments

Comments
 (0)