Hey everyone. I was playing around with the protocols/deftype stuff
and ran into a weird NullPointerException when calling the satisfies?
function. Seems to only happen with a java.lang.Object instance.

Clojure 1.2.0-master-SNAPSHOT
user=> (defprotocol Greeter (greet [this]))
Greeter
user=> (satisfies? Greeter nil)
false
user=> (satisfies? Greeter "")
false
user=> (satisfies? Greeter (Object.))
java.lang.NullPointerException (NO_SOURCE_FILE:0)

Narrowed it down to this function:

;; core_deftype.clj
(defn find-protocol-impl [protocol x]
  (if (instance? (:on-interface protocol) x)
    x
    (let [c (class x)
          impl #(get (:impls protocol) %)]
      (or (impl c)
          (and c (or (first (remove nil? (map impl (butlast (super-chain c)))))
                     (when-let [t (reduce pref (filter impl (disj
(supers c) Object)))]
                       (impl t))
                     (impl Object)))))))

More specifically, here:

(disj (supers c) Object)

Since in this case, `c` is java.lang.Object, supers returns nil which
disj doesn't seem to like. Shouldn't disj handle nil gracefully?

Thanks,
Allen

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to