@@ -79,6 +79,7 @@ public struct JSSending<T>: @unchecked Sendable {
7979 }
8080}
8181
82+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
8283extension JSSending where T == JSObject {
8384 private init ( _ object: JSObject , transferring: Bool ) {
8485 self . init (
@@ -165,6 +166,7 @@ extension JSSending where T == JSObject {
165166 }
166167}
167168
169+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
168170extension JSSending {
169171
170172 /// Receives a sent `JSObject` from a thread.
@@ -227,6 +229,8 @@ extension JSSending {
227229 #endif
228230 }
229231
232+ // 6.0 and below can't compile the following without a compiler crash.
233+ #if compiler(>=6.1)
230234 /// Receives multiple `JSSending` instances from a thread in a single operation.
231235 ///
232236 /// This method is more efficient than receiving multiple objects individually, as it
@@ -257,10 +261,12 @@ extension JSSending {
257261 /// - isolation: The actor isolation context for this call, used in Swift concurrency.
258262 /// - Returns: A tuple containing the received objects.
259263 /// - Throws: `JSSendingError` if any sending operation fails, or `JSException` if a JavaScript error occurs.
264+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
260265 public static func receive< each U > (
261266 _ sendings: repeat JSSending < each U > ,
262267 isolation: isolated ( any Actor ) ? = #isolation, file: StaticString = #file, line: UInt = #line
263268 ) async throws -> ( repeat each U ) where T == ( repeat each U ) {
269+ #if compiler(>=6.1) && _runtime(_multithreaded)
264270 var sendingObjects : [ JavaScriptObjectRef ] = [ ]
265271 var transferringObjects : [ JavaScriptObjectRef ] = [ ]
266272 var sourceTid : Int32 ?
@@ -302,9 +308,14 @@ extension JSSending {
302308 return sending. storage. construct ( result. object!)
303309 }
304310 return ( repeat extract( each sendings) )
311+ #else
312+ return try await ( repeat ( each sendings) . receive ( ) )
313+ #endif
305314 }
315+ #endif // compiler(>=6.1)
306316}
307317
318+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
308319fileprivate final class _JSSendingContext : Sendable {
309320 let continuation : CheckedContinuation < JavaScriptObjectRef , Error >
310321
0 commit comments