@@ -64,6 +64,8 @@ public class JSClosure: JSFunction, JSClosureProtocol {
64
64
private var hostFuncRef : JavaScriptHostFuncRef = 0
65
65
66
66
#if JAVASCRIPTKIT_WITHOUT_WEAKREFS
67
+ private let file : String
68
+ private let line : UInt32
67
69
private var isReleased : Bool = false
68
70
#endif
69
71
@@ -77,6 +79,10 @@ public class JSClosure: JSFunction, JSClosureProtocol {
77
79
}
78
80
79
81
public init ( _ body: @escaping ( [ JSValue ] ) -> JSValue , file: String = #fileID, line: UInt32 = #line) {
82
+ #if JAVASCRIPTKIT_WITHOUT_WEAKREFS
83
+ self . file = file
84
+ self . line = line
85
+ #endif
80
86
// 1. Fill `id` as zero at first to access `self` to get `ObjectIdentifier`.
81
87
super. init ( id: 0 )
82
88
@@ -94,15 +100,15 @@ public class JSClosure: JSFunction, JSClosureProtocol {
94
100
95
101
#if compiler(>=5.5)
96
102
@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
97
- public static func async ( _ body: @escaping ( [ JSValue ] ) async throws -> JSValue ) -> JSClosure {
98
- JSClosure ( makeAsyncClosure ( body) )
103
+ public static func async ( _ body: @escaping ( [ JSValue ] ) async throws -> JSValue , file : String = #fileID , line : UInt32 = #line ) -> JSClosure {
104
+ JSClosure ( makeAsyncClosure ( body) , file : file , line : line )
99
105
}
100
106
#endif
101
107
102
108
#if JAVASCRIPTKIT_WITHOUT_WEAKREFS
103
109
deinit {
104
110
guard isReleased else {
105
- fatalError ( " release() must be called on JSClosure objects manually before they are deallocated " )
111
+ fatalError ( " release() must be called on JSClosure object ( \( file ) : \( line ) ) manually before they are deallocated" )
106
112
}
107
113
}
108
114
#endif
0 commit comments