@@ -1059,15 +1059,7 @@ extension Parser {
10591059 }
10601060
10611061 // Parse the signature.
1062- let signature = self . parseFunctionSignature ( )
1063-
1064- // mark the unexpected result type of initializer
1065- // and replace the ‘output‘ of signature with nil
1066- var unexpectedResultType : RawUnexpectedNodesSyntax ?
1067- if let output = signature. output {
1068- signature. raw = signature. layoutView. replacingChild ( at: 5 , with: nil , arena: self . arena)
1069- unexpectedResultType = RawUnexpectedNodesSyntax ( [ output. raw] , arena: self . arena)
1070- }
1062+ let signature = self . parseFunctionSignature ( allowOutput: false )
10711063
10721064 let whereClause : RawGenericWhereClauseSyntax ?
10731065 if self . at ( . keyword( . where) ) {
@@ -1086,7 +1078,6 @@ extension Parser {
10861078 optionalMark: failable,
10871079 genericParameterClause: generics,
10881080 signature: signature,
1089- unexpectedResultType,
10901081 genericWhereClause: whereClause,
10911082 body: items,
10921083 arena: self . arena
@@ -1398,12 +1389,12 @@ extension Parser {
13981389 }
13991390
14001391 @_spi ( RawSyntax)
1401- public mutating func parseFunctionSignature( ) -> RawFunctionSignatureSyntax {
1392+ public mutating func parseFunctionSignature( allowOutput : Bool = true ) -> RawFunctionSignatureSyntax {
14021393 let input = self . parseParameterClause ( for: . functionParameters)
14031394
14041395 var effectSpecifiers = self . parseDeclEffectSpecifiers ( )
14051396
1406- let output : RawReturnClauseSyntax ?
1397+ var output : RawReturnClauseSyntax ?
14071398
14081399 /// Only allow recovery to the arrow with exprKeyword precedence so we only
14091400 /// skip over misplaced identifiers and don't e.g. recover to an arrow in a 'where' clause.
@@ -1413,10 +1404,19 @@ extension Parser {
14131404 output = nil
14141405 }
14151406
1407+ var unexpectedAfterOutput : RawUnexpectedNodesSyntax ?
1408+ if !allowOutput,
1409+ let unexpectedOutput = output
1410+ {
1411+ output = nil
1412+ unexpectedAfterOutput = RawUnexpectedNodesSyntax ( [ unexpectedOutput. raw] , arena: self . arena)
1413+ }
1414+
14161415 return RawFunctionSignatureSyntax (
14171416 input: input,
14181417 effectSpecifiers: effectSpecifiers,
14191418 output: output,
1419+ unexpectedAfterOutput,
14201420 arena: self . arena
14211421 )
14221422 }
0 commit comments