Skip to content

Commit 0339eee

Browse files
committed
Fix up some availability issues w.r.t. sendable metatypes
1 parent 6861af7 commit 0339eee

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Sources/AsyncAlgorithms/AsyncShareSequence.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Synchronization
1313
import DequeModule
1414

1515
@available(AsyncAlgorithms 1.1, *)
16-
extension AsyncSequence where Element: Sendable, Self: SendableMetatype, AsyncIterator: SendableMetatype {
16+
extension AsyncSequence where Element: Sendable, Self: _AsyncSequenceSendableMetatype, AsyncIterator: _AsyncIteratorSendableMetatype {
1717
/// Creates a shared async sequence that allows multiple concurrent iterations over a single source.
1818
///
1919
/// The `share` method transforms an async sequence into a shareable sequence that can be safely
@@ -107,7 +107,7 @@ extension AsyncSequence where Element: Sendable, Self: SendableMetatype, AsyncIt
107107
// This type is typically not used directly; instead, use the `share()` method on any
108108
// async sequence that meets the sendability requirements.
109109
@available(AsyncAlgorithms 1.1, *)
110-
struct AsyncShareSequence<Base: AsyncSequence>: Sendable where Base.Element: Sendable, Base: SendableMetatype, Base.AsyncIterator: SendableMetatype {
110+
struct AsyncShareSequence<Base: AsyncSequence>: Sendable where Base.Element: Sendable, Base: _AsyncSequenceSendableMetatype, Base.AsyncIterator: _AsyncIteratorSendableMetatype {
111111
// Represents a single consumer's connection to the shared sequence.
112112
//
113113
// Each iterator of the shared sequence creates its own `Side` instance, which tracks
@@ -586,7 +586,7 @@ struct AsyncShareSequence<Base: AsyncSequence>: Sendable where Base.Element: Sen
586586
if let factory {
587587
let task: Task<Void, Never>
588588
// for the fancy dance of availability and canImport see the comment on the next check for details
589-
#if canImport(_Concurrency, _version: 6.2)
589+
#if swift(>=6.2)
590590
if #available(macOS 26.0, iOS 26.0, tvOS 26.0, visionOS 26.0, *) {
591591
task = Task(name: "Share Iteration") { [factory, self] in
592592
await iterationLoop(factory: factory)
@@ -616,7 +616,9 @@ struct AsyncShareSequence<Base: AsyncSequence>: Sendable where Base.Element: Sen
616616
// the _Concurrency library. This menas for Darwin based OSes we have to have a fallback at runtime,
617617
// and for non-darwin OSes we need to verify against the ability to import that version.
618618
// Using this priority escalation means that the base task can avoid being detached.
619-
#if canImport(_Concurrency, _version: 6.2)
619+
//
620+
// This is disabled for now until the 9999 availability is removed from `withTaskPriorityEscalationHandler`
621+
#if false /*swift(>=6.2)*/
620622
if #available(macOS 26.0, iOS 26.0, tvOS 26.0, visionOS 26.0, *) {
621623
return try await withTaskPriorityEscalationHandler {
622624
return await nextIteration(id)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#if compiler(>=6.2)
2+
public typealias _AsyncSequenceSendableMetatype = SendableMetatype
3+
public typealias _AsyncIteratorSendableMetatype = SendableMetatype
4+
#else
5+
public typealias _AsyncSequenceSendableMetatype = Any
6+
public typealias _AsyncIteratorSendableMetatype = Any
7+
#endif

0 commit comments

Comments
 (0)