Skip to content

Commit 69cfc17

Browse files
authored
SE-300 revisions in response to review (#1302)
* SE-300 revisions in response to review: - Fix lingering references to `CheckedContinuation<T>` without an error argument - Include covariant overload of `resume(with:)` for typed `Result`s; this is implemented in the standard library but I forgot to include it in the proposal * Mark proposal as accepted
1 parent 130066d commit 69cfc17

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

proposals/0300-continuation.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Proposal: [SE-0300](0300-continuation.md)
44
* Authors: [John McCall](https://github.com/rjmccall), [Joe Groff](https://github.com/jckarter), [Doug Gregor](https://github.com/DougGregor), [Konrad Malawski](https://github.com/ktoso)
55
* Review Manager: [Ben Cohen](https://github.com/airspeedswift)
6-
* Status: **Active Review (March 2 - 9, 2021)**
6+
* Status: **Accepted**
77
* Previous Revisions: [1](https://github.com/apple/swift-evolution/blob/5f79481244329ec2860951c0c49c101aef5069e7/proposals/0300-continuation.md), [2](https://github.com/apple/swift-evolution/blob/61c788cdb9674c99fc8731b49056cebcb5497edd/proposals/0300-continuation.md)
88

99
## Introduction
@@ -84,6 +84,12 @@ extension UnsafeContinuation where T == Void {
8484
func resume() { resume(returning: ()) }
8585
}
8686

87+
extension UnsafeContinuation where T == Error {
88+
// Allow covariant use of a `Result` with a stricter error type than
89+
// the continuation:
90+
func resume<ResultError: Error>(with result: Result<T, ResultError>)
91+
}
92+
8793
func withUnsafeContinuation<T>(
8894
_ operation: (UnsafeContinuation<T, Never>) -> ()
8995
) async -> T
@@ -188,12 +194,18 @@ extension CheckedContinuation where T == Void {
188194
func resume()
189195
}
190196

197+
extension CheckedContinuation where T == Error {
198+
// Allow covariant use of a `Result` with a stricter error type than
199+
// the continuation:
200+
func resume<ResultError: Error>(with result: Result<T, ResultError>)
201+
}
202+
191203
func withCheckedContinuation<T>(
192-
_ operation: (CheckedContinuation<T>) -> ()
204+
_ operation: (CheckedContinuation<T, Never>) -> ()
193205
) async -> T
194206

195207
func withCheckedThrowingContinuation<T>(
196-
_ operation: (CheckedContinuation<T>) throws -> ()
208+
_ operation: (CheckedContinuation<T, Error>) throws -> ()
197209
) async throws -> T
198210
```
199211

0 commit comments

Comments
 (0)