From b639ffe0db1f98a8ce95eb726336b464314d1691 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Fri, 14 Nov 2025 18:20:45 +0100 Subject: [PATCH 1/2] Revert "Remove added group around base type in `AttributedTypeSyntax`" This reverts commit d022b8b9596f1456ea485c32b49c425905010813. --- .../SwiftFormat/PrettyPrint/TokenStreamCreator.swift | 3 +++ .../PrettyPrint/FunctionTypeTests.swift | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift index f56f50e6..46a805a2 100644 --- a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift +++ b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift @@ -2411,6 +2411,9 @@ private final class TokenStreamCreator: SyntaxVisitor { ) } + before(node.baseType.firstToken(viewMode: .sourceAccurate), tokens: .open) + after(node.baseType.lastToken(viewMode: .sourceAccurate), tokens: .close) + after(node.lastToken(viewMode: .sourceAccurate), tokens: .close) return .visitChildren } diff --git a/Tests/SwiftFormatTests/PrettyPrint/FunctionTypeTests.swift b/Tests/SwiftFormatTests/PrettyPrint/FunctionTypeTests.swift index d7b7f30c..2bb5b326 100644 --- a/Tests/SwiftFormatTests/PrettyPrint/FunctionTypeTests.swift +++ b/Tests/SwiftFormatTests/PrettyPrint/FunctionTypeTests.swift @@ -316,15 +316,15 @@ final class FunctionTypeTests: PrettyPrintTestCase { expected: """ func f( _ body: - nonisolated(nonsending) () - async -> Void + nonisolated(nonsending) + () async -> Void ) {} func f( _ body: @Foo @Bar - nonisolated(nonsending) () - async -> Void + nonisolated(nonsending) + () async -> Void ) {} func f( @@ -336,8 +336,8 @@ final class FunctionTypeTests: PrettyPrintTestCase { func f( _ body: inout @Foo @Bar - nonisolated(nonsending) () - async -> Void + nonisolated(nonsending) + () async -> Void ) {} """, From 2ee5237a65b91fd98329b5ffd54ff74eb85ed7f9 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Fri, 14 Nov 2025 18:19:38 +0100 Subject: [PATCH 2/2] Format source code and run `git diff` instead of listing first The diff yields more insightful results than `swift-format lint` --- .github/workflows/pull_request.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 6beedf44..1220863a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -44,8 +44,21 @@ jobs: swift /tmp/cross-pr-checkout.swift "${{ github.repository }}" "${{ github.event.number }}" - name: Build run: swift build --configuration release + - name: Write check script + run: | + cat > /tmp/check-formatting.sh <