Skip to content

Commit 9835c1a

Browse files
Inherit isolation from the closure definition context
The unnecessary `sending` and `@Sendable` attributes are removed from the parameters so that they can inherit the isolation from the closure definition site. https://github.com/swiftlang/swift-evolution/blob/main/proposals/0461-async-function-isolation.md#isolation-inference-for-closures
1 parent cc62d17 commit 9835c1a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class JSOneshotClosure: JSObject, JSClosureProtocol {
5454
priority: TaskPriority? = nil,
5555
file: String = #fileID,
5656
line: UInt32 = #line,
57-
_ body: sending @escaping (sending [JSValue]) async throws(JSException) -> JSValue
57+
_ body: @escaping (sending [JSValue]) async throws(JSException) -> JSValue
5858
) -> JSOneshotClosure {
5959
JSOneshotClosure(file: file, line: line, makeAsyncClosure(priority: priority, body))
6060
}
@@ -71,7 +71,7 @@ public class JSOneshotClosure: JSObject, JSClosureProtocol {
7171
priority: TaskPriority? = nil,
7272
file: String = #fileID,
7373
line: UInt32 = #line,
74-
_ body: @Sendable @escaping (sending [JSValue]) async throws(JSException) -> JSValue
74+
_ body: @escaping (sending [JSValue]) async throws(JSException) -> JSValue
7575
) -> JSOneshotClosure {
7676
JSOneshotClosure(
7777
file: file,
@@ -176,7 +176,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
176176
priority: TaskPriority? = nil,
177177
file: String = #fileID,
178178
line: UInt32 = #line,
179-
_ body: sending @escaping @isolated(any) (sending [JSValue]) async throws(JSException) -> JSValue
179+
_ body: @escaping @isolated(any) (sending [JSValue]) async throws(JSException) -> JSValue
180180
) -> JSClosure {
181181
JSClosure(file: file, line: line, makeAsyncClosure(priority: priority, body))
182182
}
@@ -193,7 +193,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
193193
priority: TaskPriority? = nil,
194194
file: String = #fileID,
195195
line: UInt32 = #line,
196-
_ body: sending @escaping (sending [JSValue]) async throws(JSException) -> JSValue
196+
_ body: @escaping (sending [JSValue]) async throws(JSException) -> JSValue
197197
) -> JSClosure {
198198
JSClosure(file: file, line: line, makeAsyncClosure(executorPreference: taskExecutor, priority: priority, body))
199199
}
@@ -212,7 +212,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
212212
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
213213
private func makeAsyncClosure(
214214
priority: TaskPriority?,
215-
_ body: sending @escaping @isolated(any) (sending [JSValue]) async throws(JSException) -> JSValue
215+
_ body: @escaping @isolated(any) (sending [JSValue]) async throws(JSException) -> JSValue
216216
) -> ((sending [JSValue]) -> JSValue) {
217217
{ arguments in
218218
JSPromise { resolver in
@@ -241,7 +241,7 @@ private func makeAsyncClosure(
241241
private func makeAsyncClosure(
242242
executorPreference taskExecutor: (any TaskExecutor)?,
243243
priority: TaskPriority?,
244-
_ body: sending @escaping (sending [JSValue]) async throws(JSException) -> JSValue
244+
_ body: @escaping (sending [JSValue]) async throws(JSException) -> JSValue
245245
) -> ((sending [JSValue]) -> JSValue) {
246246
{ arguments in
247247
JSPromise { resolver in

0 commit comments

Comments
 (0)