@@ -84,8 +84,8 @@ public class JSFunction: JSObject, _JSFunctionProtocol {
84
84
public var `throws` : JSThrowingFunction {
85
85
JSThrowingFunction ( self )
86
86
}
87
+ #endif
87
88
88
- #else
89
89
@discardableResult
90
90
public func callAsFunction( arguments: [ JSValue ] ) -> JSValue {
91
91
invokeNonThrowingJSFunction ( arguments: arguments) . jsValue
@@ -98,7 +98,6 @@ public class JSFunction: JSObject, _JSFunctionProtocol {
98
98
}
99
99
}
100
100
}
101
- #endif
102
101
103
102
@available ( * , unavailable, message: " Please use JSClosure instead " )
104
103
public static func from( _: @escaping ( [ JSValue ] ) -> JSValue ) -> JSFunction {
@@ -109,15 +108,15 @@ public class JSFunction: JSObject, _JSFunctionProtocol {
109
108
. function( self )
110
109
}
111
110
112
- #if hasFeature(Embedded)
113
111
final func invokeNonThrowingJSFunction( arguments: [ JSValue ] ) -> RawJSValue {
114
112
arguments. withRawJSValues { invokeNonThrowingJSFunction ( rawValues: $0) }
115
113
}
116
114
117
115
final func invokeNonThrowingJSFunction( arguments: [ JSValue ] , this: JSObject ) -> RawJSValue {
118
116
arguments. withRawJSValues { invokeNonThrowingJSFunction ( rawValues: $0, this: this) }
119
117
}
120
- #else
118
+
119
+ #if !hasFeature(Embedded)
121
120
final func invokeNonThrowingJSFunction( arguments: [ ConvertibleToJSValue ] ) -> RawJSValue {
122
121
arguments. withRawJSValues { invokeNonThrowingJSFunction ( rawValues: $0) }
123
122
}
@@ -164,11 +163,14 @@ public class JSFunction: JSObject, _JSFunctionProtocol {
164
163
}
165
164
}
166
165
166
+ /// Internal protocol to support generic arguments for `JSFunction`.
167
+ ///
168
+ /// In Swift Embedded, non-final classes cannot have generic methods.
167
169
public protocol _JSFunctionProtocol : JSFunction { }
168
170
169
171
#if hasFeature(Embedded)
172
+ // NOTE: once embedded supports variadic generics, we can remove these overloads
170
173
public extension _JSFunctionProtocol {
171
- // hand-made "varidacs" for Embedded
172
174
173
175
@discardableResult
174
176
func callAsFunction( this: JSObject ) -> JSValue {
0 commit comments