Repository: swiftlang/swift-syntax (swift)

Issue:
`:` is not applied in the correct place for function signature Fix-It
### Description

https://github.com/apple/swift-syntax/pull/1549#discussion_r1179896824
Test case `testInvalid13`

### Steps to Reproduce

_No response_

Pull request description:
# Goal

To solve issue https://github.com/apple/swift-syntax/issues/1608.

## Notes

There are some `TODOs` in the code I want to solve but I didn't know how. Any help is appreciated. Thank you.

Patch:
diff --git a/Sources/SwiftParser/Parameters.swift b/Sources/SwiftParser/Parameters.swift
index 83867b21b9a..f689060d75b 100644
--- a/Sources/SwiftParser/Parameters.swift
+++ b/Sources/SwiftParser/Parameters.swift
@@ -92,10 +92,30 @@ extension Parser {
     let modifiers = parseParameterModifiers(isClosure: false)
     let misplacedSpecifiers = parseMisplacedSpecifiers()
 
-    let names = self.parseParameterNames()
+    var names = self.parseParameterNames()
     let (unexpectedBeforeColon, colon) = self.expect(.colon)
 
-    let type = self.parseType(misplacedSpecifiers: misplacedSpecifiers)
+    let type: RawTypeSyntax
+
+    if colon.presence == .missing, let secondName = names.secondName, secondName.tokenText.isStartingWithUppercase {
+      // Synthesize the secondName parameter as a type node.
+      type = RawTypeSyntax(
+        RawSimpleTypeIdentifierSyntax(
+          name: secondName,
+          genericArgumentClause: nil,
+          arena: self.arena
+        )
+      )
+      names = ParameterNames(
+        unexpectedBeforeFirstName: names.unexpectedBeforeFirstName,
+        firstName: names.firstName,
+        unexpectedBeforeSecondName: nil,
+        secondName: nil
+      )
+    } else {
+      // Parse the type node as we would normally do.
+      type = self.parseType(misplacedSpecifiers: misplacedSpecifiers)
+    }
 
     let ellipsis = self.consumeIfContextualPunctuator("...", remapping: .ellipsis)
 


Test patch:
diff --git a/Tests/SwiftParserTest/translated/InvalidTests.swift b/Tests/SwiftParserTest/translated/InvalidTests.swift
index b411b4f91a6..e94655871e4 100644
--- a/Tests/SwiftParserTest/translated/InvalidTests.swift
+++ b/Tests/SwiftParserTest/translated/InvalidTests.swift
@@ -312,19 +312,19 @@ final class InvalidTests: XCTestCase {
       do {
         class Starfish {}
         struct Salmon {}
-        func f(s Starfish1️⃣,
+        func f(s 1️⃣Starfish,
                   _ ss: Salmon) -> [Int] {}
         func g() { f(Starfish(), Salmon()) }
       }
       """,
       diagnostics: [
-        DiagnosticSpec(message: "expected ':' and type in parameter", fixIts: ["insert ':' and type"])
+        DiagnosticSpec(message: "expected ':' in parameter", fixIts: ["insert ':'"])
       ],
       fixedSource: """
         do {
           class Starfish {}
           struct Salmon {}
-          func f(s Starfish: <#type#>,
+          func f(s: Starfish,
                     _ ss: Salmon) -> [Int] {}
           func g() { f(Starfish(), Salmon()) }
         }