Skip to content

Commit

Permalink
Fix #666: 'static' methods now use Reflect as well
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Feb 1, 2022
1 parent f00628d commit 141bf4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/sci/impl/interop.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#?(:clj
(Reflector/invokeStaticMethod class (str method-name) (object-array args))
:cljs (if-let [method (gobject/get class method-name)]
(.apply method class (into-array args))
(js/Reflect.apply method class (into-array args))
(let [method-name (str method-name)
field (get-static-field [class method-name])]
(cond
Expand Down
9 changes: 6 additions & 3 deletions test/sci/interop_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@
(let [func-without-apply (let [f (fn [_ _ _] 0)]
(js/Object.setPrototypeOf f nil)
f)]
(is (tu/eval* "(.f foo)"
{:classes {:allow :all
'foo #js {:f func-without-apply}}})))))
(is (= 0 (tu/eval* "(.f foo)"
{:classes {:allow :all
'foo #js {:f func-without-apply}}})))
(is (= 0 (tu/eval* "(foo/f)"
{:classes {:allow :all
'foo #js {:f func-without-apply}}}))))))

#?(:cljs
(deftest field-access-test
Expand Down

0 comments on commit 141bf4c

Please sign in to comment.