File tree 1 file changed +9
-3
lines changed
Sources/JavaScriptKit/FundamentalObjects
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -64,12 +64,18 @@ public class JSOneshotClosure: JSObject, JSClosureProtocol {
64
64
public class JSClosure : JSFunction , JSClosureProtocol {
65
65
66
66
class SharedJSClosure {
67
- private var storage : [ JavaScriptHostFuncRef : ( object: JSObject , body: ( sending [ JSValue ] ) -> JSValue ) ] = [ : ]
67
+ // Note: 6.0 compilers built with assertions enabled crash when calling
68
+ // `removeValue(forKey:)` on a dictionary with value type containing
69
+ // `sending`. Wrap the value type with a struct to avoid the crash.
70
+ struct Entry {
71
+ let item : ( object: JSObject , body: ( sending [ JSValue ] ) -> JSValue )
72
+ }
73
+ private var storage : [ JavaScriptHostFuncRef : Entry ] = [ : ]
68
74
init ( ) { }
69
75
70
76
subscript( _ key: JavaScriptHostFuncRef ) -> ( object: JSObject , body: ( sending [ JSValue ] ) -> JSValue ) ? {
71
- get { storage [ key] }
72
- set { storage [ key] = newValue }
77
+ get { storage [ key] ? . item }
78
+ set { storage [ key] = newValue. map { Entry ( item : $0 ) } }
73
79
}
74
80
}
75
81
You can’t perform that action at this time.
0 commit comments