16
16
[ns ]
17
17
(.replace (str ns ) \- \_))
18
18
19
- (defn ^:private throw-on-varargs
20
- " Throws an exception if arglist contains a varargs declaration.
21
- Protocol/interface method impls defined with deftype, defrecord, and reify
22
- don't support varags."
23
- [arglist]
24
- (when (some #(= '& %) arglist)
25
- (throw (IllegalArgumentException.
26
- " No varargs support for definterface and defprotocol method sigs;
27
- ditto for method impls defined with deftype, defrecord, and reify." ))))
28
-
29
- (defn ^:private throw-on-varargs-or-destr
30
- " Throws an exception if arglist contains a varargs declaration or a
31
- destructuring form.
32
- Protocol/interface method signatures shouldn't use varargs/destructuring."
33
- [arglist]
34
- (when (some #(or (= '& %) (coll? %)) arglist)
35
- (throw (IllegalArgumentException.
36
- " No varargs nor destructuring support for definterface and defprotocol method sigs." ))))
37
-
38
19
; for now, built on gen-interface
39
20
(defmacro definterface
40
21
" Creates a new Java interface with the given name and method sigs.
@@ -48,7 +29,6 @@ ditto for method impls defined with deftype, defrecord, and reify."))))
48
29
[name & sigs]
49
30
(let [tag (fn [x] (or (:tag (meta x)) Object))
50
31
psig (fn [[name [& args]]]
51
- (throw-on-varargs-or-destr args)
52
32
(vector name (vec (map tag args)) (tag name) (map meta args)))
53
33
cname (with-meta (symbol (str (namespace-munge *ns*) " ." name)) (meta name))]
54
34
`(let []
@@ -81,7 +61,6 @@ ditto for method impls defined with deftype, defrecord, and reify."))))
81
61
(disj 'Object 'java.lang.Object)
82
62
vec)
83
63
methods (map (fn [[name params & body]]
84
- (throw-on-varargs params)
85
64
(cons name (maybe-destructured params body)))
86
65
(apply concat (vals impls)))]
87
66
(when-let [bad-opts (seq (remove #{:no-print } (keys opts)))]
@@ -626,8 +605,6 @@ ditto for method impls defined with deftype, defrecord, and reify."))))
626
605
(if (vector? (first rs))
627
606
(recur (conj as (first rs)) (next rs))
628
607
[(seq as) (first rs)]))]
629
- (doseq [arglist arglists]
630
- (throw-on-varargs-or-destr arglist))
631
608
(when (some #{0 } (map count arglists))
632
609
(throw (IllegalArgumentException. (str " Protocol fn: " mname " must take at least one arg" ))))
633
610
(assoc m (keyword mname)
0 commit comments