Skip to content

Commit ffdfff0

Browse files
committed
require compiler v5.5 for async code
1 parent a31c67e commit ffdfff0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/JavaScriptKit/BasicObjects/JSPromise.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public final class JSPromise: JSBridgedClass {
7575
return JSPromise(unsafelyWrapping: jsObject.then!(closure).object!)
7676
}
7777

78+
#if compiler(>=5.5)
7879
/// Schedules the `success` closure to be invoked on successful completion of `self`.
7980
@discardableResult
8081
public func then(success: @escaping (JSValue) async -> ConvertibleToJSValue) -> JSPromise {
@@ -83,6 +84,7 @@ public final class JSPromise: JSBridgedClass {
8384
}
8485
return JSPromise(unsafelyWrapping: jsObject.then!(closure).object!)
8586
}
87+
#endif
8688

8789
/// Schedules the `success` closure to be invoked on successful completion of `self`.
8890
@discardableResult
@@ -97,6 +99,7 @@ public final class JSPromise: JSBridgedClass {
9799
return JSPromise(unsafelyWrapping: jsObject.then!(successClosure, failureClosure).object!)
98100
}
99101

102+
#if compiler(>=5.5)
100103
/// Schedules the `success` closure to be invoked on successful completion of `self`.
101104
@discardableResult
102105
public func then(success: @escaping (JSValue) async -> ConvertibleToJSValue,
@@ -109,6 +112,7 @@ public final class JSPromise: JSBridgedClass {
109112
}
110113
return JSPromise(unsafelyWrapping: jsObject.then!(successClosure, failureClosure).object!)
111114
}
115+
#endif
112116

113117
/// Schedules the `failure` closure to be invoked on rejected completion of `self`.
114118
@discardableResult
@@ -119,6 +123,7 @@ public final class JSPromise: JSBridgedClass {
119123
return .init(unsafelyWrapping: jsObject.catch!(closure).object!)
120124
}
121125

126+
#if compiler(>=5.5)
122127
/// Schedules the `failure` closure to be invoked on rejected completion of `self`.
123128
@discardableResult
124129
public func `catch`(failure: @escaping (JSValue) async -> ConvertibleToJSValue) -> JSPromise {
@@ -127,6 +132,7 @@ public final class JSPromise: JSBridgedClass {
127132
}
128133
return .init(unsafelyWrapping: jsObject.catch!(closure).object!)
129134
}
135+
#endif
130136

131137
/// Schedules the `failure` closure to be invoked on either successful or rejected
132138
/// completion of `self`.

Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public class JSClosure: JSObject, JSClosureProtocol {
105105
#endif
106106
}
107107

108+
#if compiler(>=5.5)
108109
private func makeAsyncClosure(_ body: @escaping ([JSValue]) async throws -> JSValue) -> (([JSValue]) -> JSValue) {
109110
{ arguments in
110111
JSPromise { resolver in
@@ -123,7 +124,7 @@ private func makeAsyncClosure(_ body: @escaping ([JSValue]) async throws -> JSVa
123124
}.jsValue()
124125
}
125126
}
126-
127+
#endif
127128

128129
// MARK: - `JSClosure` mechanism note
129130
//

0 commit comments

Comments
 (0)