Skip to content

Commit 7884a65

Browse files
authored
Fix calls of deprecated withTaskCancellationHandler version (Alamofire#3657)
### Goals ⚽ `withTaskCancellationHandler(handler:operation:)` has been deprecated in Swift 5.7 in favor of `withTaskCancellationHandler(operation:onCancel:)` (see swiftlang/swift#60569). This PR updates all calls of the former function accordingly. ### Implementation Details 🚧 n/a ### Testing Details 🔍 n/a
1 parent bdecb2c commit 7884a65

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Source/Concurrency.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ public struct DataTask<Value> {
118118
get async {
119119
if shouldAutomaticallyCancel {
120120
return await withTaskCancellationHandler {
121-
self.cancel()
122-
} operation: {
123121
await task.value
122+
} onCancel: {
123+
self.cancel()
124124
}
125125
} else {
126126
return await task.value
@@ -287,13 +287,13 @@ extension DataRequest {
287287
-> DataTask<Value> {
288288
let task = Task {
289289
await withTaskCancellationHandler {
290-
self.cancel()
291-
} operation: {
292290
await withCheckedContinuation { continuation in
293291
onResponse {
294292
continuation.resume(returning: $0)
295293
}
296294
}
295+
} onCancel: {
296+
self.cancel()
297297
}
298298
}
299299

@@ -311,9 +311,9 @@ public struct DownloadTask<Value> {
311311
get async {
312312
if shouldAutomaticallyCancel {
313313
return await withTaskCancellationHandler {
314-
self.cancel()
315-
} operation: {
316314
await task.value
315+
} onCancel: {
316+
self.cancel()
317317
}
318318
} else {
319319
return await task.value
@@ -496,13 +496,13 @@ extension DownloadRequest {
496496
-> DownloadTask<Value> {
497497
let task = Task {
498498
await withTaskCancellationHandler {
499-
self.cancel()
500-
} operation: {
501499
await withCheckedContinuation { continuation in
502500
onResponse {
503501
continuation.resume(returning: $0)
504502
}
505503
}
504+
} onCancel: {
505+
self.cancel()
506506
}
507507
}
508508

0 commit comments

Comments
 (0)