@@ -671,7 +671,8 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
671671 calledExpression: ( arrayExpr
672672 elements: ( arrayElement expression: ( genericSpecializationExpr) @element) ) @@array
673673 arguments: _* @args
674- trailingClosure: @tc)
674+ trailingClosure: @tc
675+ additionalTrailingClosures: _* @additional)
675676 =>
676677 call_expr {
677678 let callee = tree_at!(
@@ -683,7 +684,8 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
683684 tree!( ( call_expr
684685 callee: { callee}
685686 argument: { args}
686- argument: ( argument value: { tc} ) ) )
687+ argument: ( argument value: { tc} )
688+ argument: { additional} ) )
687689 }
688690 ) ,
689691 rule!(
@@ -704,23 +706,28 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
704706 ) ,
705707 // A function/method call (`foo(1, 2)`). `calledExpression` is the callee
706708 // and `arguments` is an (elided) list of `labeledExpr`, each translated
707- // to an `argument` below. A trailing closure (`xs.map { … }`) becomes a
708- // final unlabelled argument; that variant is matched first.
709- rule!(
710- ( functionCallExpr calledExpression: @callee arguments: _* @args trailingClosure: @tc)
711- =>
712- ( call_expr callee: { callee} argument: { args} argument: ( argument value: { tc} ) )
713- ) ,
709+ // to an `argument` below. A trailing closure (`xs.map { … }`) becomes
710+ // a final unlabelled argument, followed by any additional labeled
711+ // trailing closures.
714712 rule!(
715- ( functionCallExpr calledExpression: @@rawCallee arguments: _* @args)
713+ ( functionCallExpr
714+ calledExpression: @@rawCallee
715+ arguments: _* @args
716+ trailingClosure: _? @trailing
717+ additionalTrailingClosures: _* @additional)
716718 =>
717719 expr {
718720 // Always translate the callee in non-pattern context.
719721 let callee = ctx. scoped( |ctx| {
720722 ctx. in_pattern = false ;
721723 ctx. translate( rawCallee)
722724 } ) ?;
723- tree!( ( call_expr callee: { callee} argument: { args} ) )
725+ tree!( ( call_expr
726+ callee: { callee}
727+ argument: { args}
728+ argument: { trailing. map( |trailing| tree!( ( argument value: { trailing} ) ) ) }
729+ argument: { additional}
730+ ) )
724731 }
725732 ) ,
726733 // A call or enum-case pattern argument.
@@ -1019,9 +1026,17 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
10191026 // subscripts their own shape needs only a `subscript_expr` node in
10201027 // ast_types.yml and a remap here.
10211028 rule!(
1022- ( subscriptCallExpr calledExpression: @callee arguments: _* @args)
1029+ ( subscriptCallExpr
1030+ calledExpression: @callee
1031+ arguments: _* @args
1032+ trailingClosure: _? @trailing
1033+ additionalTrailingClosures: _* @additional)
10231034 =>
1024- ( call_expr callee: { callee} argument: { args} )
1035+ ( call_expr
1036+ callee: { callee}
1037+ argument: { args}
1038+ argument: { trailing. map( |trailing| tree!( ( argument value: { trailing} ) ) ) }
1039+ argument: { additional} )
10251040 ) ,
10261041 // ---- Optionals and errors ----
10271042 // Optional chaining — unwrap the marker
0 commit comments