Skip to content

Commit bcdcb3d

Browse files
authored
Fix warnings introduced in Xcode 14.1 (#1388)
* Fix warnings introduced in Xcode 14.1 * wip
1 parent f8f0d52 commit bcdcb3d

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

Examples/VoiceMemos/VoiceMemos/AudioRecorderClient/LiveAudioRecorderClient.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ private actor AudioRecorder {
7979
}
8080
}
8181

82-
guard let action = try await stream.first(where: { @Sendable _ in true })
83-
else { throw CancellationError() }
84-
return action
82+
for try await didFinish in stream {
83+
return didFinish
84+
}
85+
throw CancellationError()
8586
}
8687
}
8788

Sources/ComposableArchitecture/Internal/TaskCancellableValue.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ extension Task where Failure == Error {
22
var cancellableValue: Success {
33
get async throws {
44
try await withTaskCancellationHandler {
5-
self.cancel()
6-
} operation: {
75
try await self.value
6+
} onCancel: {
7+
self.cancel()
88
}
99
}
1010
}
@@ -15,9 +15,9 @@ extension Task where Failure == Never {
1515
var cancellableValue: Success {
1616
get async {
1717
await withTaskCancellationHandler {
18-
self.cancel()
19-
} operation: {
2018
await self.value
19+
} onCancel: {
20+
self.cancel()
2121
}
2222
}
2323
}

Sources/ComposableArchitecture/Store.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,13 @@ public final class Store<State, Action> {
409409
var index = tasks.wrappedValue.startIndex
410410
while index < tasks.wrappedValue.endIndex {
411411
defer { index += 1 }
412-
tasks.wrappedValue[index].cancel()
412+
await tasks.wrappedValue[index].value
413413
}
414-
} operation: {
414+
} onCancel: {
415415
var index = tasks.wrappedValue.startIndex
416416
while index < tasks.wrappedValue.endIndex {
417417
defer { index += 1 }
418-
await tasks.wrappedValue[index].value
418+
tasks.wrappedValue[index].cancel()
419419
}
420420
}
421421
}

Sources/ComposableArchitecture/ViewStore.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ public final class ViewStore<State, Action>: ObservableObject {
252252
public func send(_ action: Action, while predicate: @escaping (State) -> Bool) async {
253253
let task = self.send(action)
254254
await withTaskCancellationHandler {
255-
task.rawValue?.cancel()
256-
} operation: {
257255
await self.yield(while: predicate)
256+
} onCancel: {
257+
task.rawValue?.cancel()
258258
}
259259
}
260260

@@ -274,9 +274,9 @@ public final class ViewStore<State, Action>: ObservableObject {
274274
) async {
275275
let task = withAnimation(animation) { self.send(action) }
276276
await withTaskCancellationHandler {
277-
task.rawValue?.cancel()
278-
} operation: {
279277
await self.yield(while: predicate)
278+
} onCancel: {
279+
task.rawValue?.cancel()
280280
}
281281
}
282282

@@ -296,8 +296,6 @@ public final class ViewStore<State, Action>: ObservableObject {
296296
} else {
297297
let cancellable = Box<AnyCancellable?>(wrappedValue: nil)
298298
try? await withTaskCancellationHandler {
299-
cancellable.wrappedValue?.cancel()
300-
} operation: {
301299
try Task.checkCancellation()
302300
try await withUnsafeThrowingContinuation {
303301
(continuation: UnsafeContinuation<Void, Error>) in
@@ -313,6 +311,8 @@ public final class ViewStore<State, Action>: ObservableObject {
313311
_ = cancellable
314312
}
315313
}
314+
} onCancel: {
315+
cancellable.wrappedValue?.cancel()
316316
}
317317
}
318318
}

0 commit comments

Comments
 (0)