@@ -1039,15 +1039,7 @@ extension Parser {
1039
1039
}
1040
1040
1041
1041
// Parse the signature.
1042
- let signature = self . parseFunctionSignature ( )
1043
-
1044
- // mark the unexpected result type of initializer
1045
- // and replace the ‘output‘ of signature with nil
1046
- var unexpectedResultType : RawUnexpectedNodesSyntax ?
1047
- if let output = signature. output {
1048
- signature. raw = signature. layoutView. replacingChild ( at: 5 , with: nil , arena: self . arena)
1049
- unexpectedResultType = RawUnexpectedNodesSyntax ( [ output. raw] , arena: self . arena)
1050
- }
1042
+ let signature = self . parseFunctionSignature ( allowOutput: false )
1051
1043
1052
1044
let whereClause : RawGenericWhereClauseSyntax ?
1053
1045
if self . at ( . keyword( . where) ) {
@@ -1066,7 +1058,6 @@ extension Parser {
1066
1058
optionalMark: failable,
1067
1059
genericParameterClause: generics,
1068
1060
signature: signature,
1069
- unexpectedResultType,
1070
1061
genericWhereClause: whereClause,
1071
1062
body: items,
1072
1063
arena: self . arena
@@ -1378,23 +1369,32 @@ extension Parser {
1378
1369
}
1379
1370
1380
1371
@_spi ( RawSyntax)
1381
- public mutating func parseFunctionSignature( ) -> RawFunctionSignatureSyntax {
1372
+ public mutating func parseFunctionSignature( allowOutput : Bool = true ) -> RawFunctionSignatureSyntax {
1382
1373
let input = self . parseParameterClause ( for: . functionParameters)
1383
1374
1384
1375
var effectSpecifiers = self . parseDeclEffectSpecifiers ( )
1385
1376
1386
- let output : RawReturnClauseSyntax ?
1377
+ var output : RawReturnClauseSyntax ?
1387
1378
1388
1379
if self . at ( . arrow) || self . canRecoverTo ( TokenSpec ( . arrow, allowAtStartOfLine: false ) ) != nil {
1389
1380
output = self . parseFunctionReturnClause ( effectSpecifiers: & effectSpecifiers, allowNamedOpaqueResultType: true )
1390
1381
} else {
1391
1382
output = nil
1392
1383
}
1393
1384
1385
+ var unexpectedAfterOutput : RawUnexpectedNodesSyntax ?
1386
+ if !allowOutput,
1387
+ let unexpectedOutput = output
1388
+ {
1389
+ output = nil
1390
+ unexpectedAfterOutput = RawUnexpectedNodesSyntax ( [ unexpectedOutput. raw] , arena: self . arena)
1391
+ }
1392
+
1394
1393
return RawFunctionSignatureSyntax (
1395
1394
input: input,
1396
1395
effectSpecifiers: effectSpecifiers,
1397
1396
output: output,
1397
+ unexpectedAfterOutput,
1398
1398
arena: self . arena
1399
1399
)
1400
1400
}
0 commit comments