|
3 | 3 | * Proposal: [SE-0300](0300-continuation.md)
|
4 | 4 | * 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)
|
5 | 5 | * Review Manager: [Ben Cohen](https://github.com/airspeedswift)
|
6 |
| -* Status: **Active Review (March 2 - 9, 2021)** |
| 6 | +* Status: **Accepted** |
7 | 7 | * 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)
|
8 | 8 |
|
9 | 9 | ## Introduction
|
@@ -84,6 +84,12 @@ extension UnsafeContinuation where T == Void {
|
84 | 84 | func resume() { resume(returning: ()) }
|
85 | 85 | }
|
86 | 86 |
|
| 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 | + |
87 | 93 | func withUnsafeContinuation<T>(
|
88 | 94 | _ operation: (UnsafeContinuation<T, Never>) -> ()
|
89 | 95 | ) async -> T
|
@@ -188,12 +194,18 @@ extension CheckedContinuation where T == Void {
|
188 | 194 | func resume()
|
189 | 195 | }
|
190 | 196 |
|
| 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 | + |
191 | 203 | func withCheckedContinuation<T>(
|
192 |
| - _ operation: (CheckedContinuation<T>) -> () |
| 204 | + _ operation: (CheckedContinuation<T, Never>) -> () |
193 | 205 | ) async -> T
|
194 | 206 |
|
195 | 207 | func withCheckedThrowingContinuation<T>(
|
196 |
| - _ operation: (CheckedContinuation<T>) throws -> () |
| 208 | + _ operation: (CheckedContinuation<T, Error>) throws -> () |
197 | 209 | ) async throws -> T
|
198 | 210 | ```
|
199 | 211 |
|
|
0 commit comments