From 1095b6eb9714aba178ef42ba5faebe192a8d3001 Mon Sep 17 00:00:00 2001 From: broken-circle <252359939+broken-circle@users.noreply.github.com> Date: Sat, 16 May 2026 09:36:09 -0700 Subject: [PATCH] Build `AddCompletionHandler` body as `CodeBlockSyntax` `CodeBlockSyntax` now conforms to `SyntaxExpressibleByStringInterpolation`, so build the synthesized function body directly as a `CodeBlockSyntax` literal rather than parsing an `ExprSyntax` and wrapping it. --- .../SwiftSyntaxMacroExpansionTest/PeerMacroTests.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Tests/SwiftSyntaxMacroExpansionTest/PeerMacroTests.swift b/Tests/SwiftSyntaxMacroExpansionTest/PeerMacroTests.swift index 0a9eaebcf6c..89d133e72ff 100644 --- a/Tests/SwiftSyntaxMacroExpansionTest/PeerMacroTests.swift +++ b/Tests/SwiftSyntaxMacroExpansionTest/PeerMacroTests.swift @@ -102,15 +102,13 @@ final class PeerMacroTests: XCTestCase { let call: ExprSyntax = "\(funcDecl.name)(\(raw: callArguments.joined(separator: ", ")))" - // FIXME: We should make CodeBlockSyntax ExpressibleByStringInterpolation, - // so that the full body could go here. - let newBody: ExprSyntax = + let newBody: CodeBlockSyntax = """ - + { Task { completionHandler(await \(call)) } - + } """ // Drop the @addCompletionHandler attribute from the new declaration. @@ -126,7 +124,7 @@ final class PeerMacroTests: XCTestCase { newFunc.signature.returnClause = nil // drop result type newFunc.signature.parameterClause.parameters = newParameterList newFunc.signature.parameterClause.trailingTrivia = [] - newFunc.body = CodeBlockSyntax { newBody } + newFunc.body = newBody newFunc.attributes = newAttributeList return [DeclSyntax(newFunc)]