File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
Tests/SwiftParserTest/translated Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -92,10 +92,30 @@ extension Parser {
92
92
let modifiers = parseParameterModifiers ( isClosure: false )
93
93
let misplacedSpecifiers = parseMisplacedSpecifiers ( )
94
94
95
- let names = self . parseParameterNames ( )
95
+ var names = self . parseParameterNames ( )
96
96
let ( unexpectedBeforeColon, colon) = self . expect ( . colon)
97
97
98
- let type = self . parseType ( misplacedSpecifiers: misplacedSpecifiers)
98
+ let type : RawTypeSyntax
99
+
100
+ if colon. presence == . missing, let secondName = names. secondName, secondName. tokenText. isStartingWithUppercase {
101
+ // Synthesize the secondName parameter as a type node.
102
+ type = RawTypeSyntax (
103
+ RawSimpleTypeIdentifierSyntax (
104
+ name: secondName,
105
+ genericArgumentClause: nil ,
106
+ arena: self . arena
107
+ )
108
+ )
109
+ names = ParameterNames (
110
+ unexpectedBeforeFirstName: names. unexpectedBeforeFirstName,
111
+ firstName: names. firstName,
112
+ unexpectedBeforeSecondName: nil ,
113
+ secondName: nil
114
+ )
115
+ } else {
116
+ // Parse the type node as we would normally do.
117
+ type = self . parseType ( misplacedSpecifiers: misplacedSpecifiers)
118
+ }
99
119
100
120
let ellipsis = self . consumeIfContextualPunctuator ( " ... " , remapping: . ellipsis)
101
121
Original file line number Diff line number Diff line change @@ -312,19 +312,19 @@ final class InvalidTests: XCTestCase {
312
312
do {
313
313
class Starfish {}
314
314
struct Salmon {}
315
- func f(s Starfish1️⃣ ,
315
+ func f(s 1️⃣Starfish ,
316
316
_ ss: Salmon) -> [Int] {}
317
317
func g() { f(Starfish(), Salmon()) }
318
318
}
319
319
""" ,
320
320
diagnostics: [
321
- DiagnosticSpec ( message: " expected ':' and type in parameter " , fixIts: [ " insert ':' and type " ] )
321
+ DiagnosticSpec ( message: " expected ':' in parameter " , fixIts: [ " insert ':' " ] )
322
322
] ,
323
323
fixedSource: """
324
324
do {
325
325
class Starfish {}
326
326
struct Salmon {}
327
- func f(s Starfish: <#type#> ,
327
+ func f(s: Starfish ,
328
328
_ ss: Salmon) -> [Int] {}
329
329
func g() { f(Starfish(), Salmon()) }
330
330
}
You can’t perform that action at this time.
0 commit comments