From e77cc52182ff89213360f008a21a08761058f5e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 14:30:57 +0000 Subject: [PATCH 1/2] Initial plan From 600204bb12cf5abcc308edaa6cfe4976aa0eb88b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 14:38:42 +0000 Subject: [PATCH 2/2] Fix spaces around module selectors in generics (#2657) Add `::` to the list of operators allowed inside generic angle brackets in the tokenizer, preventing `<` from being misidentified as an operator when a module selector appears in generic type parameters. Co-authored-by: calda <1811727+calda@users.noreply.github.com> --- Sources/Tokenizer.swift | 2 +- Tests/Rules/SpaceAroundOperatorsTests.swift | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Sources/Tokenizer.swift b/Sources/Tokenizer.swift index 8ad7e318e..0ae79dc58 100644 --- a/Sources/Tokenizer.swift +++ b/Sources/Tokenizer.swift @@ -1964,7 +1964,7 @@ public func tokenize(_ source: String) -> [Token] { switch token { case let .operator(string, _): switch string { - case ".", "==", "?", "!", "&", "->", "~": + case ".", "==", "?", "!", "&", "->", "~", "::": if index(of: .nonSpaceOrCommentOrLinebreak, before: count - 1) == scopeIndex { // These are allowed in a generic, but not as the first character fallthrough diff --git a/Tests/Rules/SpaceAroundOperatorsTests.swift b/Tests/Rules/SpaceAroundOperatorsTests.swift index 0713d97f1..1178e2d73 100644 --- a/Tests/Rules/SpaceAroundOperatorsTests.swift +++ b/Tests/Rules/SpaceAroundOperatorsTests.swift @@ -1208,4 +1208,18 @@ final class SpaceAroundOperatorsTests: XCTestCase { """ testFormatting(for: input, rule: .spaceAroundOperators) } + + func testNoSpaceAroundGenericWithModuleSelector() { + let input = """ + let x: AnyPublisher + """ + testFormatting(for: input, rule: .spaceAroundOperators) + } + + func testNoSpaceAroundGenericWithModuleSelectorMultipleParams() { + let input = """ + let x: Result + """ + testFormatting(for: input, rule: .spaceAroundOperators) + } }