File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 148
148
:protocol-duped-method true
149
149
:protocol-multiple-impls true
150
150
:protocol-with-variadic-method true
151
+ :protocol-with-overwriting-method true
151
152
:protocol-impl-with-variadic-method true
152
153
:protocol-impl-recur-with-target true
153
154
:single-segment-namespace true
398
399
(str " Protocol " (:protocol info) " declares method "
399
400
(:name info) " with variadic signature (&)" ))
400
401
402
+ (defmethod error-message :protocol-with-overwriting-method
403
+ [warning-type info]
404
+ (let [overwritten-protocol (-> info :existing :protocol )]
405
+ (str " Protocol " (:protocol info) " is overwriting "
406
+ (if overwritten-protocol " method" " function" )
407
+ " " (:name info)
408
+ (when overwritten-protocol (str " of protocol " (name overwritten-protocol))))))
409
+
401
410
(defmethod error-message :protocol-impl-with-variadic-method
402
411
[warning-type info]
403
412
(str " Protocol " (:protocol info) " implements method "
Original file line number Diff line number Diff line change 2121
2121
(cljs.analyzer/warning
2122
2122
:protocol-with-variadic-method
2123
2123
&env {:protocol psym :name fname}))
2124
+ _ (core/when-some [existing (core/get (-> &env :ns :defs ) fname)]
2125
+ (core/when-not (= p (:protocol existing))
2126
+ (cljs.analyzer/warning
2127
+ :protocol-with-overwriting-method
2128
+ {} {:protocol psym :name fname :existing existing})))
2124
2129
slot (symbol (core/str prefix (munge (name fname))))
2125
2130
fname (vary-meta fname assoc
2126
2131
:protocol p
Original file line number Diff line number Diff line change 1875
1875
:with-core? true })]
1876
1876
(is (zero? (count @ws)))))
1877
1877
1878
+ (deftest test-cljs-2247
1879
+ (let [ws (atom [])]
1880
+ (try
1881
+ (a/with-warning-handlers [(collecting-warning-handler ws)]
1882
+ (e/with-compiler-env (assoc @test-cenv :repl-env {})
1883
+ (a/analyze (ana/empty-env )
1884
+ '(defn -foo []))
1885
+ (a/analyze (ana/empty-env )
1886
+ '(defprotocol IAlpha (-foo [this])))))
1887
+ (catch Exception _))
1888
+ (is (= [" Protocol IAlpha is overwriting function -foo" ] @ws))))
1889
+
1878
1890
(deftest test-cljs-2385-infer-priority
1879
1891
(let [ws (atom [])
1880
1892
res (infer-test-helper
You can’t perform that action at this time.
0 commit comments