Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

track protocol implementers

  • Loading branch information...
commit 2cbfff439fd6d223db25cb7ad4f744501460608d 1 parent c827c22
@swannodette swannodette authored
Showing with 21 additions and 15 deletions.
  1. +2 −1  src/clj/cljs/analyzer.clj
  2. +19 −14 src/clj/cljs/core.clj
View
3  src/clj/cljs/analyzer.clj
@@ -341,7 +341,8 @@
{:protocol protocol})
;; symbol for reified protocol
(when-let [protocol-symbol (-> sym meta :protocol-symbol)]
- {:protocol-symbol protocol-symbol})
+ {:protocol-symbol protocol-symbol
+ :impls #{}})
(when fn-var?
{:fn-var true
;; protocol implementation context
View
33 src/clj/cljs/core.clj
@@ -550,19 +550,24 @@
(defn to-property [sym]
(symbol (core/str "-" sym)))
-(defn warn-and-update-protocol [p env]
+(defn warn-and-update-protocol [p type env]
(when-not (= 'Object p)
- (if (:undeclared cljs.analyzer/*cljs-warnings*)
- (if-let [var (cljs.analyzer/resolve-existing-var (dissoc env :locals) p)]
- (do
- (when-not (:protocol-symbol var)
- (cljs.analyzer/warning env
- (core/str "WARNING: Symbol " p " is not a protocol")))
- (when (and (:protocol-deprecated cljs.analyzer/*cljs-warnings*)
- (-> var :deprecated)
- (not (-> p meta :deprecation-nowarn)))
- (cljs.analyzer/warning env
- (core/str "WARNING: Protocol " p " is deprecated"))))
+ (if-let [var (cljs.analyzer/resolve-existing-var (dissoc env :locals) p)]
+ (do
+ (when-not (:protocol-symbol var)
+ (cljs.analyzer/warning env
+ (core/str "WARNING: Symbol " p " is not a protocol")))
+ (when (and (:protocol-deprecated cljs.analyzer/*cljs-warnings*)
+ (-> var :deprecated)
+ (not (-> p meta :deprecation-nowarn)))
+ (cljs.analyzer/warning env
+ (core/str "WARNING: Protocol " p " is deprecated")))
+ (when (:protocol-symbol var)
+ (swap! cljs.analyzer/namespaces
+ (fn [ns]
+ (update-in ns [(:ns var) :defs (symbol (name p)) :impls]
+ conj type)))))
+ (when (:undeclared cljs.analyzer/*cljs-warnings*)
(cljs.analyzer/warning env
(core/str "WARNING: Can't resolve protocol symbol " p))))))
@@ -579,7 +584,7 @@
(if (base-type tsym)
(let [t (base-type tsym)
assign-impls (fn [[p sigs]]
- (warn-and-update-protocol p &env)
+ (warn-and-update-protocol p tsym &env)
(let [psym (resolve p)
pfn-prefix (subs (core/str psym) 0 (clojure.core/inc (.indexOf (core/str psym) "/")))]
(cons `(aset ~psym ~t true)
@@ -591,7 +596,7 @@
prototype-prefix (fn [sym]
`(.. ~tsym -prototype ~(to-property sym)))
assign-impls (fn [[p sigs]]
- (warn-and-update-protocol p &env)
+ (warn-and-update-protocol p t &env)
(let [psym (resolve p)
pprefix (protocol-prefix psym)]
(if (= p 'Object)
Please sign in to comment.
Something went wrong with that request. Please try again.