Skip to content

Commit c2be0bd

Browse files
committed
Add test case for async try foo()
Ensure that we emit the proper diagnostics for when the await and try are flipped, but also await is incorrectly spelled `async`. We're expecting two diagnostics, both of which have fix-its that do the right thing. One will just replace the `async` with an `await`. The other will move the text so that try comes first. Because `await` and `async` are both have the same number of characters, both fix-its will fix the issue correctly.
1 parent 49bfcd2 commit c2be0bd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/Concurrency/await_typo_correction.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ func async() throws { }
1414
// expected-error@+1 {{found 'async' in expression; did you mean 'await'?}}{{9-14=await}}
1515
try async asyncFunc()
1616

17+
// expected-error@+2 {{found 'async' in expression; did you mean 'await'?}}{{5-10=await}}
18+
// expected-warning@+1 {{'try' must precede 'await'}}{{5-11=}}{{15-15=await }}
19+
async try asyncFunc()
20+
1721
// expected-error@+1 {{found 'async' in expression; did you mean 'await'?}}{{13-18=await}}
1822
let _ = async anotherAsyncFunc()
1923

0 commit comments

Comments
 (0)