Skip to content

Commit 875fa81

Browse files
committed
Speculative fix for pre 6.1 compiler crashes by removing the sending keyword
1 parent 769d31c commit 875fa81

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Sources/AsyncAlgorithms/AsyncShareSequence.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ where Base.Element: Sendable, Base: AsyncSequenceSendableMetatype, Base.AsyncIte
342342
let state: Mutex<State>
343343
let limit: Int?
344344

345+
#if compiler(>=6.1)
345346
init(
346347
_ iteratorFactory: @escaping @Sendable () -> sending Base.AsyncIterator,
347348
bufferingPolicy: AsyncBufferSequencePolicy
@@ -354,7 +355,20 @@ where Base.Element: Sendable, Base: AsyncSequenceSendableMetatype, Base.AsyncIte
354355
self.limit = nil
355356
}
356357
}
357-
358+
#else
359+
init(
360+
_ iteratorFactory: @escaping @Sendable () -> Base.AsyncIterator,
361+
bufferingPolicy: AsyncBufferSequencePolicy
362+
) {
363+
state = Mutex(State(iteratorFactory, bufferingPolicy: bufferingPolicy))
364+
switch bufferingPolicy.policy {
365+
case .bounded(let limit):
366+
self.limit = limit
367+
default:
368+
self.limit = nil
369+
}
370+
}
371+
#endif
358372
func cancel() {
359373
let (task, limitContinuation, demand, cancelled) = state.withLock {
360374
state -> (IteratingTask?, UnsafeContinuation<Bool, Never>?, UnsafeContinuation<Void, Never>?, Bool) in
@@ -637,7 +651,7 @@ where Base.Element: Sendable, Base: AsyncSequenceSendableMetatype, Base.AsyncIte
637651
// Using this priority escalation means that the base task can avoid being detached.
638652
//
639653
// This is disabled for now until the 9999 availability is removed from `withTaskPriorityEscalationHandler`
640-
#if false /*compiler(>=6.2)*/
654+
#if false // replace with compiler(>=6.2)
641655
guard #available(macOS 26.0, iOS 26.0, tvOS 26.0, visionOS 26.0, *) else {
642656
return try await nextIteration(id).get()
643657
}

0 commit comments

Comments
 (0)