File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 14991499(core/defn- add-ifn-methods [type type-sym [f & meths :as form]]
15001500 (core/let [meths (map #(adapt-ifn-params type %) meths)
15011501 this-sym (with-meta 'self__ {:tag type})
1502- argsym (gensym " args" )]
1502+ argsym (gensym " args" )
1503+ max-ifn-arity 20 ]
15031504 (concat
15041505 [`(set! ~(extend-prefix type-sym 'call) ~(with-meta `(fn ~@meths) (meta form)))
15051506 `(set! ~(extend-prefix type-sym 'apply)
15061507 ~(with-meta
15071508 `(fn ~[this-sym argsym]
15081509 (this-as ~this-sym
15091510 (.apply (.-call ~this-sym) ~this-sym
1510- (.concat (array ~this-sym) (cljs.core/aclone ~argsym)))))
1511+ (.concat (array ~this-sym)
1512+ (if (> (.-length ~argsym) ~max-ifn-arity)
1513+ (doto (.slice ~argsym 0 ~max-ifn-arity)
1514+ (.push (.slice ~argsym ~max-ifn-arity)))
1515+ ~argsym)))))
15111516 (meta form)))]
15121517 (ifn-invoke-methods type type-sym form))))
15131518
Original file line number Diff line number Diff line change 4242 (is (= '(1 2 3 4 )) (apply meta-f 1 2 3 4 []))
4343 (is (= '(1 2 3 4 5 )) (apply meta-f 1 2 3 4 5 []))
4444 (is (= (range 1 8 )) (apply meta-f 1 2 3 4 5 [6 7 ]))
45- ; ; Currently: 20 is not seqable :(
46- #_ (is (= (range 21 ) (apply meta-f (range 21 )))
45+ (is (= (range 21 ) (apply meta-f (range 21 )))
4746 " Should properly call the last IFn arity with 20 args with last being a seq" )
48- ; ; Currently: Tries to call arity 21. Fault at .apply of the deftype proto
49- ; ; Though, it could probably also be caught right by apply
50- #_ (is (= (range 22 ) (apply meta-f (range 22 )))
47+ (is (= (range 22 ) (apply meta-f (range 22 )))
5148 " Should properly call the last IFn arity with 20 args with last being a seq" )
52- # _ (is (= (range 22 ) (.apply meta-f nil (to-array (range 22 ))))
49+ (is (= (range 22 ) (.apply meta-f nil (to-array (range 22 ))))
5350 " .apply should also handle >20 arguments" ))
5451
5552(deftest multi-arity-test
You can’t perform that action at this time.
0 commit comments