Skip to content

Commit fdee0ff

Browse files
committed
Move CancellationError out to the top level
1 parent eda5b4d commit fdee0ff

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

stdlib/public/Concurrency/SourceCompatibilityShims.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ import Swift
1818

1919
@available(SwiftStdlib 5.5, *)
2020
extension Task where Success == Never, Failure == Never {
21-
@available(*, deprecated, message: "use TaskPriority")
21+
@available(*, deprecated, message: "Task.Priority has been removed; use TaskPriority")
2222
public typealias Priority = TaskPriority
2323

24-
@available(*, deprecated, message: "use Task")
24+
@available(*, deprecated, message: "Task.Handle has been removed; use Task")
2525
public typealias Handle = _Concurrency.Task
26+
27+
@available(*, deprecated, message: "Task.CancellationError has been removed; use CancellationError")
28+
@_alwaysEmitIntoClient
29+
public static func CancellationError() -> _Concurrency.CancellationError {
30+
return _Concurrency.CancellationError()
31+
}
2632
}
2733

2834
@available(SwiftStdlib 5.5, *)

stdlib/public/Concurrency/TaskCancellation.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ extension Task where Success == Never, Failure == Never {
9898
throw CancellationError()
9999
}
100100
}
101+
}
101102

102-
/// The default cancellation thrown when a task is cancelled.
103-
///
104-
/// This error is also thrown automatically by `Task.checkCancellation()`,
105-
/// if the current task has been cancelled.
106-
public struct CancellationError: Error {
107-
// no extra information, cancellation is intended to be light-weight
108-
public init() {}
109-
}
103+
/// The default cancellation thrown when a task is cancelled.
104+
///
105+
/// This error is also thrown automatically by `Task.checkCancellation()`,
106+
/// if the current task has been cancelled.
107+
public struct CancellationError: Error {
108+
// no extra information, cancellation is intended to be light-weight
109+
public init() {}
110110
}
111111

112112
@available(SwiftStdlib 5.5, *)

test/Concurrency/async_task_groups.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func asyncThrowsOnCancel() async throws -> Int {
1616
await Task.sleep(1_000_000_000)
1717
}
1818

19-
throw Task.CancellationError()
19+
throw CancellationError()
2020
}
2121

2222
@available(SwiftStdlib 5.5, *)

0 commit comments

Comments
 (0)