summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2009-11-12 16:41:26 -0500
committerRich Hickey <richhickey@gmail.com>2009-11-12 16:41:26 -0500
commit63476312c7272b563ef2e07db168be91afe36149 (patch)
tree66ce72ccde8c16940b90cc688ea241c4fb681afd /src
parentbebb1ff5cb80b863a3aba2ba21eaafc843f990da (diff)
make protocol cache/satisfies? nil-tolerant, ditto supers/bases
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/core.clj9
-rw-r--r--src/clj/clojure/core_deftype.clj8
2 files changed, 9 insertions, 8 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 0b546f8f..6f96e1e1 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -3593,10 +3593,11 @@
(defn bases
"Returns the immediate superclass and direct interfaces of c, if any"
[#^Class c]
- (let [i (.getInterfaces c)
- s (.getSuperclass c)]
- (not-empty
- (if s (cons s i) i))))
+ (when c
+ (let [i (.getInterfaces c)
+ s (.getSuperclass c)]
+ (not-empty
+ (if s (cons s i) i)))))
(defn supers
"Returns the immediate and indirect superclasses and interfaces of c, if any"
diff --git a/src/clj/clojure/core_deftype.clj b/src/clj/clojure/core_deftype.clj
index c2f71d40..5aba4042 100644
--- a/src/clj/clojure/core_deftype.clj
+++ b/src/clj/clojure/core_deftype.clj
@@ -213,9 +213,9 @@
impl #(get (:impls protocol) %)]
(or (impl t)
(impl c)
- (first (remove nil? (map impl (butlast (super-chain c)))))
- (first (remove nil? (map impl (disj (supers c) Object))))
- (impl Object)))))
+ (and c (or (first (remove nil? (map impl (butlast (super-chain c)))))
+ (first (remove nil? (map impl (disj (supers c) Object))))
+ (impl Object)))))))
(defn find-protocol-method [protocol methodk x]
(get (find-protocol-impl protocol x) methodk))
@@ -244,7 +244,7 @@
(when-not f
(throw (IllegalArgumentException. (str "No implementation of method: " (.methodk cache)
" of protocol: " (:var (.protocol cache))
- " found for class: " (.getName (class x))))))
+ " found for class: " (if (nil? x) "nil" (.getName (class x)))))))
(set! (.val cache-box) (expand-method-impl-cache cache (class x) f))
f))