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 {
9292 let modifiers = parseParameterModifiers ( isClosure: false )
9393 let misplacedSpecifiers = parseMisplacedSpecifiers ( )
9494
95- let names = self . parseParameterNames ( )
95+ var names = self . parseParameterNames ( )
9696 let ( unexpectedBeforeColon, colon) = self . expect ( . colon)
9797
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+ }
99119
100120 let ellipsis = self . consumeIfContextualPunctuator ( " ... " , remapping: . ellipsis)
101121
Original file line number Diff line number Diff line change @@ -312,19 +312,19 @@ final class InvalidTests: XCTestCase {
312312 do {
313313 class Starfish {}
314314 struct Salmon {}
315- func f(s Starfish1️⃣ ,
315+ func f(s 1️⃣Starfish ,
316316 _ ss: Salmon) -> [Int] {}
317317 func g() { f(Starfish(), Salmon()) }
318318 }
319319 """ ,
320320 diagnostics: [
321- DiagnosticSpec ( message: " expected ':' and type in parameter " , fixIts: [ " insert ':' and type " ] )
321+ DiagnosticSpec ( message: " expected ':' in parameter " , fixIts: [ " insert ':' " ] )
322322 ] ,
323323 fixedSource: """
324324 do {
325325 class Starfish {}
326326 struct Salmon {}
327- func f(s Starfish: <#type#> ,
327+ func f(s: Starfish ,
328328 _ ss: Salmon) -> [Int] {}
329329 func g() { f(Starfish(), Salmon()) }
330330 }
You can’t perform that action at this time.
0 commit comments