Skip to content

Commit 51e4fd2

Browse files
committed
Address a few more warnings in the concurrency library
1 parent 4a63884 commit 51e4fd2

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

stdlib/public/Concurrency/AsyncStream.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ public struct AsyncStream<Element> {
175175
let storage: _AsyncStreamCriticalStorage<Optional<() async -> Element?>>
176176
= .create(produce)
177177
self.produce = {
178-
return await Task.withCancellationHandler {
179-
storage.value = nil
180-
onCancel?()
181-
} operation: {
178+
return await withTaskCancellationHandler {
182179
guard let result = await storage.value?() else {
183180
storage.value = nil
184181
return nil
185182
}
186183
return result
184+
} onCancel: {
185+
storage.value = nil
186+
onCancel?()
187187
}
188188
}
189189
}

stdlib/public/Concurrency/TaskCancellation.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public func withTaskCancellationHandler<T>(
3232
operation: () async throws -> T,
3333
onCancel handler: @Sendable () -> Void
3434
) async rethrows -> T {
35-
let task = Builtin.getCurrentAsyncTask()
36-
3735
// unconditionally add the cancellation record to the task.
3836
// if the task was already cancelled, it will be executed right away.
3937
let record = _taskAddCancellationHandler(handler: handler)

stdlib/public/Concurrency/TaskLocal.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
188188
// the type-checker that this property-wrapper never wants to have an enclosing
189189
// instance (it is impossible to declare a property wrapper inside the `Never`
190190
// type).
191+
@available(*, unavailable, message: "property wrappers cannot be instance members")
191192
public static subscript(
192193
_enclosingInstance object: Never,
193194
wrapped wrappedKeyPath: ReferenceWritableKeyPath<Never, Value>,

0 commit comments

Comments
 (0)