From bc3cbd3e34a33a5e1b4f31e2500ec2ba313988f6 Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Sun, 10 Apr 2016 23:38:41 -0500 Subject: [PATCH] Implement strict get RT.get now throws on non-supported types rather than returning nil Fixes #108 --- src/clj/clojure/core_deftype.clj | 3 ++- src/jvm/clojure/lang/RT.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/clj/clojure/core_deftype.clj b/src/clj/clojure/core_deftype.clj index 9af010e3..42254aaf 100644 --- a/src/clj/clojure/core_deftype.clj +++ b/src/clj/clojure/core_deftype.clj @@ -532,7 +532,8 @@ (defn- protocol? [maybe-p] - (boolean (:on-interface maybe-p))) + (try (boolean (:on-interface maybe-p)) + (catch Exception _ false))) (defn- implements? [protocol atype] (and atype (.isAssignableFrom ^Class (:on-interface protocol) atype))) diff --git a/src/jvm/clojure/lang/RT.java b/src/jvm/clojure/lang/RT.java index af1ec25a..d865fe2a 100644 --- a/src/jvm/clojure/lang/RT.java +++ b/src/jvm/clojure/lang/RT.java @@ -809,7 +809,7 @@ static Object getFrom(Object coll, Object key) { return null; } - return null; + throw new IllegalArgumentException("get not supported on type: " + coll.getClass().getName()); } static public Object get(Object coll, Object key, Object notFound) {