summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clj/clojure/core_deftype.clj9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/clj/clojure/core_deftype.clj b/src/clj/clojure/core_deftype.clj
index 40d21c7d..4dc27d3a 100644
--- a/src/clj/clojure/core_deftype.clj
+++ b/src/clj/clojure/core_deftype.clj
@@ -387,10 +387,13 @@
(defn find-protocol-method [protocol methodk x]
(get (find-protocol-impl protocol x) methodk))
+(defn- implements? [protocol atype]
+ (.isAssignableFrom #^Class (:on-interface protocol) atype))
+
(defn extends?
"Returns true if atype extends protocol"
[protocol atype]
- (boolean (or (.isAssignableFrom #^Class (:on-interface protocol) atype)
+ (boolean (or (implements? protocol atype)
(get (:impls protocol) atype))))
(defn extenders
@@ -598,6 +601,10 @@
[atype & proto+mmaps]
(doseq [[proto mmap] (partition 2 proto+mmaps)]
+ (when (implements? proto atype)
+ (throw (IllegalArgumentException.
+ (str atype " already directly implements " (:on-interface proto) " for protocol:"
+ (:var proto)))))
(-reset-methods (alter-var-root (:var proto) assoc-in [:impls atype] mmap))))
(defn- emit-impl [[p fs]]