Skip to content

Commit 87aab10

Browse files
committed
[test]: update existing tests for SingleValueExpr fixit
1 parent 8b591ae commit 87aab10

File tree

3 files changed

+74
-74
lines changed

3 files changed

+74
-74
lines changed

test/expr/unary/do_expr.swift

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,12 @@ func tryDo30(_ fn: () throws -> Int) rethrows -> Int {
423423

424424
func awaitDo1() async -> Int {
425425
await do { 0 }
426-
// expected-warning@-1 {{'await' has no effect on 'do' expression}}
426+
// expected-warning@-1 {{'await' has no effect on 'do' expression}}{{3-9=}}
427427
}
428428

429429
func awaitDo2() async -> Int {
430430
let x = await do { 0 }
431-
// expected-warning@-1 {{'await' has no effect on 'do' expression}}
431+
// expected-warning@-1 {{'await' has no effect on 'do' expression}}{{11-17=}}
432432
return x
433433
}
434434

@@ -439,65 +439,65 @@ func awaitDo3() -> Int { // expected-note {{add 'async' to function 'awaitDo3()'
439439

440440
func awaitDo4() async -> Int {
441441
return await do { 0 }
442-
// expected-warning@-1 {{'await' has no effect on 'do' expression}}
442+
// expected-warning@-1 {{'await' has no effect on 'do' expression}}{{10-16=}}
443443
}
444444

445445
func awaitDo5() async -> Int {
446446
return await do { awaitDo4() }
447-
// expected-warning@-1 {{'await' has no effect on 'do' expression}}
447+
// expected-warning@-1 {{'await' has no effect on 'do' expression}}{{10-16=}}
448448
// expected-warning@-2 {{expression is 'async' but is not marked with 'await'}}
449449
// expected-note@-3 {{call is 'async'}}
450450
}
451451

452452
func awaitDo6() async -> Int {
453453
await do { awaitDo4() }
454-
// expected-warning@-1 {{'await' has no effect on 'do' expression}}
454+
// expected-warning@-1 {{'await' has no effect on 'do' expression}}{{3-9=}}
455455
// expected-warning@-2 {{expression is 'async' but is not marked with 'await'}}
456456
// expected-note@-3 {{call is 'async'}}
457457
}
458458

459459
func awaitDo7() async -> Int {
460460
let x = await do { awaitDo4() }
461-
// expected-warning@-1 {{'await' has no effect on 'do' expression}}
461+
// expected-warning@-1 {{'await' has no effect on 'do' expression}}{{11-17=}}
462462
// expected-warning@-2 {{expression is 'async' but is not marked with 'await'}}
463463
// expected-note@-3 {{call is 'async'}}
464464
return x
465465
}
466466

467467
func awaitDo8() async -> Int {
468468
return await do { await awaitDo4() }
469-
// expected-warning@-1 {{'await' has no effect on 'do' expression}}
469+
// expected-warning@-1 {{'await' has no effect on 'do' expression}}{{10-16=}}
470470
}
471471

472472
func awaitDo9() async -> Int {
473473
await do { await awaitDo4() }
474-
// expected-warning@-1 {{'await' has no effect on 'do' expression}}
474+
// expected-warning@-1 {{'await' has no effect on 'do' expression}}{{3-9=}}
475475
}
476476

477477
func awaitDo10() async -> Int {
478478
let x = await do { await awaitDo4() }
479-
// expected-warning@-1 {{'await' has no effect on 'do' expression}}
479+
// expected-warning@-1 {{'await' has no effect on 'do' expression}}{{11-17=}}
480480
return x
481481
}
482482

483483
func awaitDo11() async -> Int {
484484
let x = await do { try await tryAwaitDo1() } catch { awaitDo4() }
485-
// expected-warning@-1 {{'await' has no effect on 'do-catch' expression}}
485+
// expected-warning@-1 {{'await' has no effect on 'do-catch' expression}}{{11-17=}}
486486
// expected-warning@-2 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
487487
// expected-note@-3 {{call is 'async'}}
488488
return x
489489
}
490490

491491
func awaitDo12() async -> Int {
492492
let x = await do { try tryAwaitDo1() } catch { awaitDo4() }
493-
// expected-warning@-1 {{'await' has no effect on 'do-catch' expression}}
493+
// expected-warning@-1 {{'await' has no effect on 'do-catch' expression}}{{11-17=}}
494494
// expected-warning@-2 2{{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
495495
// expected-note@-3 2{{call is 'async'}}
496496
return x
497497
}
498498

499499
func awaitDo13() async throws -> Int {
500-
let x = await do { // expected-warning {{'await' has no effect on 'do-catch' expression}}
500+
let x = await do { // expected-warning {{'await' has no effect on 'do-catch' expression}}{{11-17=}}
501501
awaitDo4() // expected-warning {{result of call to 'awaitDo4()' is unused}}
502502
// expected-warning@-1 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
503503
// expected-note@-2 {{call is 'async'}}
@@ -527,13 +527,13 @@ func asyncBool() async -> Bool { true }
527527

528528
func awaitDo14() async -> Int {
529529
await do { try tryDo4() } catch _ where asyncBool() { 0 } catch { 1 }
530-
// expected-warning@-1 {{'await' has no effect on 'do-catch' expression}}
530+
// expected-warning@-1 {{'await' has no effect on 'do-catch' expression}}{{3-9=}}
531531
// expected-error@-2 {{'async' call cannot occur in a catch guard expression}}
532532
}
533533

534534
func awaitDo15() async -> Int {
535535
await do { try tryDo4() } catch _ where await asyncBool() { 0 } catch { 1 }
536-
// expected-warning@-1 {{'await' has no effect on 'do-catch' expression}}
536+
// expected-warning@-1 {{'await' has no effect on 'do-catch' expression}}{{3-9=}}
537537
// expected-error@-2 {{'async' call cannot occur in a catch guard expression}}
538538
}
539539

@@ -566,19 +566,19 @@ func awaitDo20() async -> Int {
566566
func tryAwaitDo1() async throws -> Int {
567567
try await do { 0 }
568568
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
569-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
569+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
570570
}
571571

572572
func tryAwaitDo2() async throws -> Int {
573573
try await do { 0 } as Int
574574
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
575-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
575+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
576576
}
577577

578578
func tryAwaitDo3() async throws -> Int {
579579
try await do { tryAwaitDo2() } as Int
580580
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
581-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
581+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
582582
// expected-warning@-3 {{call can throw but is not marked with 'try'; this is an error in the Swift 6 language mode}}
583583
// expected-note@-4 {{did you mean to use 'try'?}}
584584
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -590,15 +590,15 @@ func tryAwaitDo3() async throws -> Int {
590590
func tryAwaitDo4() async throws -> Int {
591591
try await do { try tryAwaitDo2() } as Int
592592
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
593-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
593+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
594594
// expected-warning@-3 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
595595
// expected-note@-4 {{call is 'async'}}
596596
}
597597

598598
func tryAwaitDo5() async throws -> Int {
599599
try await do { await tryAwaitDo2() } as Int
600600
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
601-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
601+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
602602
// expected-warning@-3 {{call can throw but is not marked with 'try'; this is an error in the Swift 6 language mode}}
603603
// expected-note@-4 {{did you mean to use 'try'?}}
604604
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -608,13 +608,13 @@ func tryAwaitDo5() async throws -> Int {
608608
func tryAwaitDo6() async throws -> Int {
609609
try await do { try await tryAwaitDo2() } as Int
610610
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
611-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
611+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
612612
}
613613

614614
func tryAwaitDo7() async throws -> Int {
615615
try await do { tryAwaitDo2() }
616616
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
617-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
617+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
618618
// expected-warning@-3 {{call can throw but is not marked with 'try'; this is an error in the Swift 6 language mode}}
619619
// expected-note@-4 {{did you mean to use 'try'?}}
620620
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -626,15 +626,15 @@ func tryAwaitDo7() async throws -> Int {
626626
func tryAwaitDo8() async throws -> Int {
627627
try await do { try tryAwaitDo2() }
628628
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
629-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
629+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
630630
// expected-warning@-3 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
631631
// expected-note@-4 {{call is 'async'}}
632632
}
633633

634634
func tryAwaitDo9() async throws -> Int {
635635
try await do { await tryAwaitDo2() }
636636
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
637-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
637+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
638638
// expected-warning@-3 {{call can throw but is not marked with 'try'; this is an error in the Swift 6 language mode}}
639639
// expected-note@-4 {{did you mean to use 'try'?}}
640640
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -644,7 +644,7 @@ func tryAwaitDo9() async throws -> Int {
644644
func tryAwaitDo10() async throws -> Int {
645645
try await do { try await tryAwaitDo2() }
646646
// expected-warning@-1 {{'try' has no effect on 'do' expression}}
647-
// expected-warning@-2 {{'await' has no effect on 'do' expression}}
647+
// expected-warning@-2 {{'await' has no effect on 'do' expression}}{{7-13=}}
648648
}
649649

650650
func tryAwaitDo11(_ fn: () async throws -> Int) async rethrows -> Int {

test/expr/unary/if_expr.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,81 +1305,81 @@ func tryIf29(_ fn: () throws -> Int) rethrows -> Int {
13051305

13061306
func awaitIf1() async -> Int {
13071307
await if .random() { 0 } else { 1 }
1308-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1308+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{3-9=}}
13091309
}
13101310

13111311
func awaitIf2() async -> Int {
13121312
let x = await if .random() { 0 } else { 1 }
1313-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1313+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{11-17=}}
13141314
return x
13151315
}
13161316

13171317
func awaitIf3() async -> Int {
13181318
return await if .random() { 0 } else { 1 }
1319-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1319+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{10-16=}}
13201320
}
13211321

13221322
func awaitIf4() async -> Int {
13231323
return await if .random() { 0 } else { 1 }
1324-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1324+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{10-16=}}
13251325
}
13261326

13271327
func awaitIf5() async -> Int {
13281328
return await if .random() { awaitIf4() } else { 1 }
1329-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1329+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{10-16=}}
13301330
// expected-warning@-2 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
13311331
// expected-note@-3 {{call is 'async'}}
13321332
}
13331333

13341334
func awaitIf6() async -> Int {
13351335
await if .random() { awaitIf4() } else { 1 }
1336-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1336+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{3-9=}}
13371337
// expected-warning@-2 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
13381338
// expected-note@-3 {{call is 'async'}}
13391339
}
13401340

13411341
func awaitIf7() async -> Int {
13421342
let x = await if .random() { awaitIf4() } else { 1 }
1343-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1343+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{11-17=}}
13441344
// expected-warning@-2 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
13451345
// expected-note@-3 {{call is 'async'}}
13461346
return x
13471347
}
13481348

13491349
func awaitIf8() async -> Int {
13501350
return await if .random() { await awaitIf4() } else { 1 }
1351-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1351+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{10-16=}}
13521352
}
13531353

13541354
func awaitIf9() async -> Int {
13551355
await if .random() { await awaitIf4() } else { 1 }
1356-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1356+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{3-9=}}
13571357
}
13581358

13591359
func awaitIf10() async -> Int {
13601360
let x = await if .random() { await awaitIf4() } else { 1 }
1361-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1361+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{11-17=}}
13621362
return x
13631363
}
13641364

13651365
func awaitIf11() async -> Int {
13661366
let x = await if .random() { await awaitIf4() } else { awaitIf4() }
1367-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1367+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{11-17=}}
13681368
// expected-warning@-2 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
13691369
// expected-note@-3 {{call is 'async'}}
13701370
return x
13711371
}
13721372

13731373
func awaitIf12() async -> Int {
13741374
let x = await if .random() { awaitIf4() } else { awaitIf4() }
1375-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1375+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{11-17=}}
13761376
// expected-warning@-2 2{{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
13771377
// expected-note@-3 2{{call is 'async'}}
13781378
return x
13791379
}
13801380

13811381
func awaitIf13() async throws -> Int {
1382-
let x = await if .random() { // expected-warning {{'await' has no effect on 'if' expression}}
1382+
let x = await if .random() { // expected-warning {{'await' has no effect on 'if' expression}}{{11-17=}}
13831383
awaitIf4() // expected-warning {{result of call to 'awaitIf4()' is unused}}
13841384
// expected-warning@-1 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
13851385
// expected-note@-2 {{call is 'async'}}
@@ -1407,14 +1407,14 @@ func asyncBool() async -> Bool { true }
14071407

14081408
func awaitIf14() async -> Int {
14091409
await if asyncBool() { 0 } else { 1 }
1410-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1410+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{3-9=}}
14111411
// expected-warning@-2 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
14121412
// expected-note@-3 {{call is 'async'}}
14131413
}
14141414

14151415
func awaitIf15() async -> Int {
14161416
await if await asyncBool() { 0 } else { 1 }
1417-
// expected-warning@-1 {{'await' has no effect on 'if' expression}}
1417+
// expected-warning@-1 {{'await' has no effect on 'if' expression}}{{3-9=}}
14181418
}
14191419

14201420
func awaitIf16() async -> Int {
@@ -1447,19 +1447,19 @@ func awaitIf20() async -> Int {
14471447
func tryAwaitIf1() async throws -> Int {
14481448
try await if .random() { 0 } else { 1 }
14491449
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1450-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1450+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
14511451
}
14521452

14531453
func tryAwaitIf2() async throws -> Int {
14541454
try await if .random() { 0 } else { 1 } as Int
14551455
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1456-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1456+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
14571457
}
14581458

14591459
func tryAwaitIf3() async throws -> Int {
14601460
try await if .random() { tryAwaitIf2() } else { 1 } as Int
14611461
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1462-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1462+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
14631463
// expected-warning@-3 {{call can throw but is not marked with 'try'; this is an error in the Swift 6 language mode}}
14641464
// expected-note@-4 {{did you mean to use 'try'?}}
14651465
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1471,15 +1471,15 @@ func tryAwaitIf3() async throws -> Int {
14711471
func tryAwaitIf4() async throws -> Int {
14721472
try await if .random() { try tryAwaitIf2() } else { 1 } as Int
14731473
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1474-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1474+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
14751475
// expected-warning@-3 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
14761476
// expected-note@-4 {{call is 'async'}}
14771477
}
14781478

14791479
func tryAwaitIf5() async throws -> Int {
14801480
try await if .random() { await tryAwaitIf2() } else { 1 } as Int
14811481
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1482-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1482+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
14831483
// expected-warning@-3 {{call can throw but is not marked with 'try'; this is an error in the Swift 6 language mode}}
14841484
// expected-note@-4 {{did you mean to use 'try'?}}
14851485
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1489,13 +1489,13 @@ func tryAwaitIf5() async throws -> Int {
14891489
func tryAwaitIf6() async throws -> Int {
14901490
try await if .random() { try await tryAwaitIf2() } else { 1 } as Int
14911491
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1492-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1492+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
14931493
}
14941494

14951495
func tryAwaitIf7() async throws -> Int {
14961496
try await if .random() { tryAwaitIf2() } else { 1 }
14971497
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1498-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1498+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
14991499
// expected-warning@-3 {{call can throw but is not marked with 'try'; this is an error in the Swift 6 language mode}}
15001500
// expected-note@-4 {{did you mean to use 'try'?}}
15011501
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1507,15 +1507,15 @@ func tryAwaitIf7() async throws -> Int {
15071507
func tryAwaitIf8() async throws -> Int {
15081508
try await if .random() { try tryAwaitIf2() } else { 1 }
15091509
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1510-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1510+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
15111511
// expected-warning@-3 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
15121512
// expected-note@-4 {{call is 'async'}}
15131513
}
15141514

15151515
func tryAwaitIf9() async throws -> Int {
15161516
try await if .random() { await tryAwaitIf2() } else { 1 }
15171517
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1518-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1518+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
15191519
// expected-warning@-3 {{call can throw but is not marked with 'try'; this is an error in the Swift 6 language mode}}
15201520
// expected-note@-4 {{did you mean to use 'try'?}}
15211521
// expected-note@-5 {{did you mean to handle error as optional value?}}
@@ -1525,7 +1525,7 @@ func tryAwaitIf9() async throws -> Int {
15251525
func tryAwaitIf10() async throws -> Int {
15261526
try await if .random() { try await tryAwaitIf2() } else { 1 }
15271527
// expected-warning@-1 {{'try' has no effect on 'if' expression}}
1528-
// expected-warning@-2 {{'await' has no effect on 'if' expression}}
1528+
// expected-warning@-2 {{'await' has no effect on 'if' expression}}{{7-13=}}
15291529
}
15301530

15311531
func tryAwaitIf11(_ fn: () async throws -> Int) async rethrows -> Int {

0 commit comments

Comments
 (0)