File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -76,15 +76,14 @@ import Swift
7676@available ( SwiftStdlib 5 . 1 , * )
7777@export ( implementation)
7878nonisolated ( nonsending)
79- public func withTaskCancellationHandler< T , E > (
80- operation: ( ) async throws ( E ) -> T ,
81- onCancel handler: @ Sendable ( ) -> Void
82- ) async throws ( E ) -> T {
79+ public func withTaskCancellationHandler< Return , Failure > (
80+ operation: nonisolated ( nonsending ) ( ) async throws ( Failure ) -> Return ,
81+ onCancel handler: sending ( ) -> Void
82+ ) async throws ( Failure ) -> Return {
8383 // unconditionally add the cancellation record to the task.
8484 // if the task was already cancelled, it will be executed right away.
8585 let record = unsafe Builtin. taskAddCancellationHandler ( handler: handler)
8686 defer { unsafe Builtin. taskRemoveCancellationHandler ( record: record) }
87-
8887 return try await operation ( )
8988}
9089
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ actor Container {
3838 num += 1 // no error, this runs synchronously on caller context
3939 } onCancel: {
4040 // this should error because cancellation is invoked concurrently
41- num += 10 // expected-error{{actor-isolated property 'num' can not be mutated from a Sendable closure }}
41+ num += 10 // expected-error{{actor-isolated property 'num' can not be mutated from a nonisolated context }}
4242 }
4343 }
4444}
You can’t perform that action at this time.
0 commit comments