diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-03-15 14:46:47 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-03-15 14:46:47 +0000 |
commit | 9979f81f862b60c03b60ad442d5a29676b1016b7 (patch) | |
tree | bce80ae7d90cdffaf5bdf81b0cf7e42d81af8ca1 /src | |
parent | c5d47859139bb5fd0a8164aca15c896d19790645 (diff) |
filter all considered methods in superclass traverse, to avoid implementing method turned final in derived
Diffstat (limited to 'src')
-rw-r--r-- | src/proxy.clj | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/proxy.clj b/src/proxy.clj index 6e3009e8..d9aceffb 100644 --- a/src/proxy.clj +++ b/src/proxy.clj @@ -138,24 +138,26 @@ (. gen (endMethod))) ;calc set of supers' non-private instance methods - (let [mm (loop [mm {} c super] + (let [mm (loop [mm {} considered #{} c super] (if c - (recur - (loop [mm mm meths (concat - (seq (. c (getDeclaredMethods))) - (seq (. c (getMethods))))] - (if meths - (let [#^java.lang.reflect.Method meth (first meths) - mods (. meth (getModifiers)) - mk [(. meth (getName)) (seq (. meth (getParameterTypes)))]] - (if (or (contains? mm mk) - (. Modifier (isPrivate mods)) - (. Modifier (isStatic mods)) - (. Modifier (isFinal mods))) - (recur mm (rest meths)) - (recur (assoc mm mk meth) (rest meths)))) - mm)) - (. c (getSuperclass))) + (let [[mm considered] + (loop [mm mm + considered considered + meths (concat + (seq (. c (getDeclaredMethods))) + (seq (. c (getMethods))))] + (if meths + (let [#^java.lang.reflect.Method meth (first meths) + mods (. meth (getModifiers)) + mk [(. meth (getName)) (seq (. meth (getParameterTypes)))]] + (if (or (considered mk) + (. Modifier (isPrivate mods)) + (. Modifier (isStatic mods)) + (. Modifier (isFinal mods))) + (recur mm (conj considered mk) (rest meths)) + (recur (assoc mm mk meth) (conj considered mk) (rest meths)))) + [mm considered]))] + (recur mm considered (. c (getSuperclass)))) mm))] ;add methods matching supers', if no mapping -> call super (doseq #^java.lang.reflect.Method meth (vals mm) |