|
| 1 | +// RUN: %target-typecheck-verify-swift -disable-availability-checking |
| 2 | + |
| 3 | +// REQUIRES: concurrency |
| 4 | +class A {} |
| 5 | +class B: A {} |
| 6 | +typealias Foo = (name: String, age: Int) |
| 7 | +func f(_ x: String) async -> String? { x } |
| 8 | +func test() async { |
| 9 | + async let result: B? = nil |
| 10 | + async let person: Foo? = nil |
| 11 | + if let result: A = result {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{22-22=await }} |
| 12 | + // expected-warning@-1 {{immutable value 'result' was never used; consider replacing with '_' or removing it}} |
| 13 | + // expected-note@-2 {{reference to async let 'result' is 'async'}} |
| 14 | + if let result: A {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{19-19= = await result}} |
| 15 | + // expected-warning@-1 {{immutable value 'result' was never used; consider replacing with '_' or removing it}} |
| 16 | + // expected-note@-2 {{reference to async let 'result' is 'async'}} |
| 17 | + if let result = result {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{19-19=await }} |
| 18 | + // expected-warning@-1 {{value 'result' was defined but never used; consider replacing with boolean test}} |
| 19 | + // expected-note@-2 {{reference to async let 'result' is 'async'}} |
| 20 | + if let result {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{16-16= = await result}} |
| 21 | + // expected-warning@-1 {{value 'result' was defined but never used; consider replacing with boolean test}} |
| 22 | + // expected-note@-2 {{reference to async let 'result' is 'async'}} |
| 23 | + if let person: Foo = person {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{24-24=await }} |
| 24 | + // expected-warning@-1 {{immutable value 'person' was never used; consider replacing with '_' or removing it}} |
| 25 | + // expected-note@-2 {{reference to async let 'person' is 'async'}} |
| 26 | + if let person: Foo {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{21-21= = await person}} |
| 27 | + // expected-warning@-1 {{immutable value 'person' was never used; consider replacing with '_' or removing it}} |
| 28 | + // expected-note@-2 {{reference to async let 'person' is 'async'}} |
| 29 | + if let person: (String, Int) = person {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{34-34=await }} |
| 30 | + // expected-warning@-1 {{immutable value 'person' was never used; consider replacing with '_' or removing it}} |
| 31 | + // expected-note@-2 {{reference to async let 'person' is 'async'}} |
| 32 | + if let person: (String, Int) {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{31-31= = await person}} |
| 33 | + // expected-warning@-1 {{immutable value 'person' was never used; consider replacing with '_' or removing it}} |
| 34 | + // expected-note@-2 {{reference to async let 'person' is 'async'}} |
| 35 | + if let person = person {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{19-19=await }} |
| 36 | + // expected-warning@-1 {{value 'person' was defined but never used; consider replacing with boolean test}} |
| 37 | + // expected-note@-2 {{reference to async let 'person' is 'async'}} |
| 38 | + if let person {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{16-16= = await person}} |
| 39 | + // expected-warning@-1 {{value 'person' was defined but never used; consider replacing with boolean test}} |
| 40 | + // expected-note@-2 {{reference to async let 'person' is 'async'}} |
| 41 | + let a = f("a") // expected-error {{expression is 'async' but is not marked with 'await'}} {{11-11=await }} |
| 42 | + // expected-warning@-1 {{initialization of immutable value 'a' was never used; consider replacing with assignment to '_' or removing it}} |
| 43 | + // expected-note@-2 {{call is 'async'}} |
| 44 | +} |
0 commit comments