diff options
author | Rich Hickey <richhickey@gmail.com> | 2010-04-06 15:56:39 -0400 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2010-04-06 15:56:39 -0400 |
commit | 1a375fd441d32877b23ddd6bf131fe4139bf4f86 (patch) | |
tree | 2e7d240e4ededf3beaf43037790765c0640ea1d8 | |
parent | f81e612cc9ff91ddefc1d86e270cd7f018701802 (diff) |
fix lookup thunks to verify target type
-rw-r--r-- | src/clj/clojure/core_deftype.clj | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/clj/clojure/core_deftype.clj b/src/clj/clojure/core_deftype.clj index 8e13902a..c054d6e0 100644 --- a/src/clj/clojure/core_deftype.clj +++ b/src/clj/clojure/core_deftype.clj @@ -147,17 +147,22 @@ (case k# ~@(mapcat (fn [fld] [(keyword fld) fld]) base-fields) (get ~'__extmap k# else#))) - `(getLookupThunk [~'this k#] - (case k# - ~@(let [gtarget (gensym) - hinted-target (with-meta gtarget {:tag tagname})] - (mapcat - (fn [fld] - [(keyword fld) - `(reify clojure.lang.ILookupThunk - (get [_ ~gtarget] (. ~hinted-target ~fld)))]) - base-fields)) - nil)))] + (let [gclass (gensym)] + `(getLookupThunk [~'this k#] + (let [~gclass (class ~'this)] + (case k# + ~@(let [gtarget (gensym) + hinted-target (with-meta gtarget {:tag tagname})] + (mapcat + (fn [fld] + [(keyword fld) + `(reify clojure.lang.ILookupThunk + (get [thunk# ~gtarget] + (if (identical? (class ~gtarget) ~gclass) + (. ~hinted-target ~fld) + thunk#)))]) + base-fields)) + nil)))))] [i m])) (idynamictype [[i m]] [(conj i 'clojure.lang.IDynamicType) |