Skip to content

Commit 487b0b1

Browse files
committed
Fix multi-arity
1 parent 37cb3da commit 487b0b1

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/basilisp/core.lpy

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7073,14 +7073,22 @@
70737073
([arg1] ...)
70747074
([arg1 & others] ...))"
70757075
[class-and-interfaces args & fs]
7076-
(let [formatted-arity (fn [method-name [arg-vec & body]]
7076+
(let [formatted-single (fn [method-name [arg-vec & body]]
7077+
[(munge method-name)
7078+
(apply list 'fn method-name (vec (concat ['this] arg-vec)) body)])
7079+
formatted-multi (fn [method-name & arities]
70777080
[(munge method-name)
7078-
(apply list 'fn method-name (vec (concat ['this] arg-vec)) body)])
7079-
methods (mapcat (fn [[method-name & body]]
7080-
(if (vector? (first body))
7081-
(formatted-arity method-name body)
7082-
(mapcat (partial formatted-arity method-name) body)))
7083-
fs)]
7081+
(apply list
7082+
'fn
7083+
method-name
7084+
(map (fn [[arg-vec & body]]
7085+
(apply list (vec (concat ['this] arg-vec)) body))
7086+
arities))])
7087+
methods (mapcat (fn [[method-name & body]]
7088+
(if (vector? (first body))
7089+
(formatted-single method-name body)
7090+
(apply formatted-multi method-name body)))
7091+
fs)]
70847092
#_(println methods)
70857093
`((get-proxy-class ~@class-and-interfaces) ~(apply hash-map methods) ~@args)))
70867094

tests/basilisp/test_proxies.lpy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@
4141
([arg1 & args] (str "i am rest " arg1 " " args))))]
4242
(is (= "hi i am 0" (.to-string p)))
4343
(is (= "i am 1 yes" (.to-string p "yes")))
44-
(is (= "i am rest first " (.to-string p "first")))
4544
(is (= "i am rest first (:yes)" (.to-string p "first" :yes))))))

0 commit comments

Comments
 (0)