Skip to content

Commit b42550d

Browse files
committed
- fix externs parsing parameter handling
1 parent a4f3ee6 commit b42550d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/main/clojure/cljs/externs.clj

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,13 @@
8888
(some-> (.getRoot texpr) parse-texpr simplify-texpr))
8989

9090
(defn params->method-params [xs]
91-
(letfn [(not-opt? [x]
92-
(not (string/starts-with? (name x) "opt_")))]
93-
(let [required (into [] (take-while not-opt? xs))
94-
opts (drop-while not-opt? xs)]
95-
(loop [ret [required] opts opts]
96-
(if-let [opt (first opts)]
97-
(recur (conj ret (conj (last ret) opt)) (drop 1 opts))
98-
(seq ret))))))
91+
(let [not-opt? (complement :optional?)
92+
required (into [] (map :name (take-while not-opt? xs)))
93+
opts (map :name (drop-while not-opt? xs))]
94+
(loop [ret [required] opts opts]
95+
(if-let [opt (first opts)]
96+
(recur (conj ret (conj (last ret) opt)) (drop 1 opts))
97+
(seq ret)))))
9998

10099
(defn generic? [t]
101100
(let [s (name t)]
@@ -136,15 +135,15 @@
136135
(if (or (.hasReturnType info)
137136
(as-> (.getParameterCount info) c
138137
(and c (pos? c))))
139-
(let [arglist (into [] (map symbol (.getParameterNames info)))
138+
(let [arglist (get-params info)
140139
arglists (params->method-params arglist)]
141140
{:tag 'Function
142141
:js-fn-var true
143142
:ret-tag (or (some-> (.getReturnType info)
144143
get-tag gtype->cljs-type)
145144
'clj-nil)
146-
:variadic? (boolean (some '#{var_args} arglist))
147-
:max-fixed-arity (count (take-while #(not= 'var_args %) arglist))
145+
:variadic? (boolean (some :var-args? arglist))
146+
:max-fixed-arity (count (take-while (complement :var-args?) arglist))
148147
:method-params arglists
149148
:arglists arglists}))))
150149
{:file *source-file*

0 commit comments

Comments
 (0)