@@ -2451,6 +2451,81 @@ class TrailingCommasTests: XCTestCase {
24512451 testFormatting ( for: input, output, rule: . trailingCommas, options: options, exclude: [ . typeSugar, . propertyTypes] )
24522452 }
24532453
2454+ func testTrailingCommasNotAddedToClosureTupleReturnType( ) {
2455+ // Trailing commas are unexpectedly not allowed here in Swift 6.2
2456+ let input = """
2457+ let closure = { () -> (
2458+ foo: String,
2459+ bar: String
2460+ ) in
2461+ (foo: " foo " , bar: " bar " )
2462+ }
2463+
2464+ func foo() -> (
2465+ foo: String,
2466+ bar: String
2467+ ) {
2468+ (foo: " foo " , bar: " bar " )
2469+ }
2470+ """
2471+
2472+ let output = """
2473+ let closure = { () -> (
2474+ foo: String,
2475+ bar: String
2476+ ) in
2477+ (foo: " foo " , bar: " bar " )
2478+ }
2479+
2480+ func foo() -> (
2481+ foo: String,
2482+ bar: String,
2483+ ) {
2484+ (foo: " foo " , bar: " bar " )
2485+ }
2486+ """
2487+
2488+ let options = FormatOptions ( trailingCommas: . always, swiftVersion: " 6.2 " )
2489+ testFormatting ( for: input, output, rule: . trailingCommas, options: options, exclude: [ . typeSugar, . propertyTypes] )
2490+ }
2491+
2492+ func testTrailingCommasAddedToClosureTupleReturnTypeSwift6_3( ) {
2493+ let input = """
2494+ let closure = { () -> (
2495+ foo: String,
2496+ bar: String
2497+ ) in
2498+ (foo: " foo " , bar: " bar " )
2499+ }
2500+
2501+ func foo() -> (
2502+ foo: String,
2503+ bar: String
2504+ ) {
2505+ (foo: " foo " , bar: " bar " )
2506+ }
2507+ """
2508+
2509+ let output = """
2510+ let closure = { () -> (
2511+ foo: String,
2512+ bar: String,
2513+ ) in
2514+ (foo: " foo " , bar: " bar " )
2515+ }
2516+
2517+ func foo() -> (
2518+ foo: String,
2519+ bar: String,
2520+ ) {
2521+ (foo: " foo " , bar: " bar " )
2522+ }
2523+ """
2524+
2525+ let options = FormatOptions ( trailingCommas: . always, swiftVersion: " 6.3 " )
2526+ testFormatting ( for: input, output, rule: . trailingCommas, options: options, exclude: [ . typeSugar, . propertyTypes] )
2527+ }
2528+
24542529 func testTrailingCommasAddedToTupleFunctionArgumentInSwift6_2( ) {
24552530 let input = """
24562531 func updateBackgroundMusic(
0 commit comments