[Concurrency] await try -> try await

The `try await` ordering is both easier to read and indicates the order
of operations better, because the suspension point occurs first and
then one can observe a thrown error.
This commit is contained in:
Doug Gregor
2020-12-23 12:35:48 -08:00
parent b99533aced
commit 3c38ffe0ea
29 changed files with 124 additions and 124 deletions

View File

@@ -19,11 +19,11 @@ func testSlowServing(p: SlowServing) async throws {
// CHECK: objc_method {{.*}} $@convention(objc_method) <τ_0_0 where τ_0_0 : SlowServing> (@convention(block) (NSString) -> (), τ_0_0) -> ()
let _: String = await p.requestString()
// CHECK: objc_method {{.*}} $@convention(objc_method) <τ_0_0 where τ_0_0 : SlowServing> (@convention(block) (Optional<NSString>, Optional<NSError>) -> (), τ_0_0) -> ()
let _: String = await try p.tryRequestString()
let _: String = try await p.tryRequestString()
// CHECK: objc_method {{.*}} $@convention(objc_method) <τ_0_0 where τ_0_0 : SlowServing> (@convention(block) (Int, NSString) -> (), τ_0_0) -> ()
let _: (Int, String) = await p.requestIntAndString()
// CHECK: objc_method {{.*}} $@convention(objc_method) <τ_0_0 where τ_0_0 : SlowServing> (@convention(block) (Int, Optional<NSString>, Optional<NSError>) -> (), τ_0_0) -> ()
let _: (Int, String) = await try p.tryRequestIntAndString()
let _: (Int, String) = try await p.tryRequestIntAndString()
}
class SlowSwiftServer: NSObject, SlowServing {