File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 148148 :protocol-duped-method true
149149 :protocol-multiple-impls true
150150 :protocol-with-variadic-method true
151+ :protocol-with-overwriting-method true
151152 :protocol-impl-with-variadic-method true
152153 :protocol-impl-recur-with-target true
153154 :single-segment-namespace true
398399 (str " Protocol " (:protocol info) " declares method "
399400 (:name info) " with variadic signature (&)" ))
400401
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+
401410(defmethod error-message :protocol-impl-with-variadic-method
402411 [warning-type info]
403412 (str " Protocol " (:protocol info) " implements method "
Original file line number Diff line number Diff line change 21212121 (cljs.analyzer/warning
21222122 :protocol-with-variadic-method
21232123 &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})))
21242129 slot (symbol (core/str prefix (munge (name fname))))
21252130 fname (vary-meta fname assoc
21262131 :protocol p
Original file line number Diff line number Diff line change 18751875 :with-core? true })]
18761876 (is (zero? (count @ws)))))
18771877
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+
18781890(deftest test-cljs-2385-infer-priority
18791891 (let [ws (atom [])
18801892 res (infer-test-helper
You can’t perform that action at this time.
0 commit comments