@@ -1059,15 +1059,7 @@ extension Parser {
1059
1059
}
1060
1060
1061
1061
// 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 )
1071
1063
1072
1064
let whereClause : RawGenericWhereClauseSyntax ?
1073
1065
if self . at ( . keyword( . where) ) {
@@ -1086,7 +1078,6 @@ extension Parser {
1086
1078
optionalMark: failable,
1087
1079
genericParameterClause: generics,
1088
1080
signature: signature,
1089
- unexpectedResultType,
1090
1081
genericWhereClause: whereClause,
1091
1082
body: items,
1092
1083
arena: self . arena
@@ -1398,12 +1389,12 @@ extension Parser {
1398
1389
}
1399
1390
1400
1391
@_spi ( RawSyntax)
1401
- public mutating func parseFunctionSignature( ) -> RawFunctionSignatureSyntax {
1392
+ public mutating func parseFunctionSignature( allowOutput : Bool = true ) -> RawFunctionSignatureSyntax {
1402
1393
let input = self . parseParameterClause ( for: . functionParameters)
1403
1394
1404
1395
var effectSpecifiers = self . parseDeclEffectSpecifiers ( )
1405
1396
1406
- let output : RawReturnClauseSyntax ?
1397
+ var output : RawReturnClauseSyntax ?
1407
1398
1408
1399
/// Only allow recovery to the arrow with exprKeyword precedence so we only
1409
1400
/// skip over misplaced identifiers and don't e.g. recover to an arrow in a 'where' clause.
@@ -1413,10 +1404,19 @@ extension Parser {
1413
1404
output = nil
1414
1405
}
1415
1406
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
+
1416
1415
return RawFunctionSignatureSyntax (
1417
1416
input: input,
1418
1417
effectSpecifiers: effectSpecifiers,
1419
1418
output: output,
1419
+ unexpectedAfterOutput,
1420
1420
arena: self . arena
1421
1421
)
1422
1422
}
0 commit comments