@@ -84,8 +84,8 @@ public class JSFunction: JSObject, _JSFunctionProtocol {
8484 public var `throws` : JSThrowingFunction {
8585 JSThrowingFunction ( self )
8686 }
87+ #endif
8788
88- #else
8989 @discardableResult
9090 public func callAsFunction( arguments: [ JSValue ] ) -> JSValue {
9191 invokeNonThrowingJSFunction ( arguments: arguments) . jsValue
@@ -98,7 +98,6 @@ public class JSFunction: JSObject, _JSFunctionProtocol {
9898 }
9999 }
100100 }
101- #endif
102101
103102 @available ( * , unavailable, message: " Please use JSClosure instead " )
104103 public static func from( _: @escaping ( [ JSValue ] ) -> JSValue ) -> JSFunction {
@@ -109,15 +108,15 @@ public class JSFunction: JSObject, _JSFunctionProtocol {
109108 . function( self )
110109 }
111110
112- #if hasFeature(Embedded)
113111 final func invokeNonThrowingJSFunction( arguments: [ JSValue ] ) -> RawJSValue {
114112 arguments. withRawJSValues { invokeNonThrowingJSFunction ( rawValues: $0) }
115113 }
116114
117115 final func invokeNonThrowingJSFunction( arguments: [ JSValue ] , this: JSObject ) -> RawJSValue {
118116 arguments. withRawJSValues { invokeNonThrowingJSFunction ( rawValues: $0, this: this) }
119117 }
120- #else
118+
119+ #if !hasFeature(Embedded)
121120 final func invokeNonThrowingJSFunction( arguments: [ ConvertibleToJSValue ] ) -> RawJSValue {
122121 arguments. withRawJSValues { invokeNonThrowingJSFunction ( rawValues: $0) }
123122 }
@@ -164,11 +163,14 @@ public class JSFunction: JSObject, _JSFunctionProtocol {
164163 }
165164}
166165
166+ /// Internal protocol to support generic arguments for `JSFunction`.
167+ ///
168+ /// In Swift Embedded, non-final classes cannot have generic methods.
167169public protocol _JSFunctionProtocol : JSFunction { }
168170
169171#if hasFeature(Embedded)
172+ // NOTE: once embedded supports variadic generics, we can remove these overloads
170173public extension _JSFunctionProtocol {
171- // hand-made "varidacs" for Embedded
172174
173175 @discardableResult
174176 func callAsFunction( this: JSObject ) -> JSValue {
0 commit comments