Speculative fix for pre 6.1 compiler crashes by removing the sending keyword

This commit is contained in:
Philippe Hausler committed 2025-09-09 10:16:08 -07:00
1 parent 769d31cb6a
commit 875fa81bc6
1 file changed
+16 -2
@@ -342,6 +342,7 @@ where Base.Element: Sendable, Base: AsyncSequenceSendableMetatype, Base.AsyncIte
let state: Mutex<State>
let limit: Int?
#if compiler(>=6.1)
init(
_ iteratorFactory: @escaping @Sendable () -> sending Base.AsyncIterator,
bufferingPolicy: AsyncBufferSequencePolicy
@@ -354,7 +355,20 @@ where Base.Element: Sendable, Base: AsyncSequenceSendableMetatype, Base.AsyncIte
self.limit = nil
}
}
#else
init(
_ iteratorFactory: @escaping @Sendable () -> Base.AsyncIterator,
bufferingPolicy: AsyncBufferSequencePolicy
) {
state = Mutex(State(iteratorFactory, bufferingPolicy: bufferingPolicy))
switch bufferingPolicy.policy {
case .bounded(let limit):
self.limit = limit
default:
self.limit = nil
}
}
#endif
func cancel() {
let (task, limitContinuation, demand, cancelled) = state.withLock {
state -> (IteratingTask?, UnsafeContinuation<Bool, Never>?, UnsafeContinuation<Void, Never>?, Bool) in
@@ -637,7 +651,7 @@ where Base.Element: Sendable, Base: AsyncSequenceSendableMetatype, Base.AsyncIte
// Using this priority escalation means that the base task can avoid being detached.
//
// This is disabled for now until the 9999 availability is removed from `withTaskPriorityEscalationHandler`
#if false /*compiler(>=6.2)*/
#if false // replace with compiler(>=6.2)
guard #available(macOS 26.0, iOS 26.0, tvOS 26.0, visionOS 26.0, *) else {
return try await nextIteration(id).get()
}