Skip to content

Commit 3417d46

Browse files
committed
CLJS-2134: Warn on variadic signatures in protocol method implementation as well
1 parent b340a6e commit 3417d46

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
:protocol-duped-method true
139139
:protocol-multiple-impls true
140140
:protocol-with-variadic-method true
141+
:protocol-impl-with-variadic-method true
141142
:protocol-impl-recur-with-target true
142143
:single-segment-namespace true
143144
:munged-namespace true
@@ -360,6 +361,11 @@
360361
(str "Protocol " (:protocol info) " declares method "
361362
(:name info) " with variadic signature (&)"))
362363

364+
(defmethod error-message :protocol-impl-with-variadic-method
365+
[warning-type info]
366+
(str "Protocol " (:protocol info) " implements method "
367+
(:name info) " with variadic signature (&)"))
368+
363369
(defmethod error-message :protocol-impl-recur-with-target
364370
[warning-type info]
365371
(str "Ignoring target object \"" (pr-str (:form info)) "\" passed in recur to protocol method head"))

src/main/clojure/cljs/core.cljc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,8 @@
14981498
c (count sig)]
14991499
(core/when (contains? seen c)
15001500
(ana/warning :protocol-duped-method env {:protocol p :fname fname}))
1501+
(core/when (some '#{&} sig)
1502+
(ana/warning :protocol-impl-with-variadic-method env {:protocol p :name fname}))
15011503
(core/when (core/and (not= decmeths ::not-found) (not (some #{c} (map count decmeths))))
15021504
(ana/warning :protocol-invalid-method env {:protocol p :fname fname :invalid-arity c}))
15031505
(recur (next sigs) (conj seen c))))))))

0 commit comments

Comments
 (0)