diff options
author | Rich Hickey <richhickey@gmail.com> | 2010-04-26 13:31:11 -0400 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2010-04-26 13:31:11 -0400 |
commit | 29dcb68be1eb9e2bfbe5bc627a1f1d6b3e0b7a29 (patch) | |
tree | 68e1e5baec52ea938910298c147d87a5770d7cf5 /src/clj | |
parent | 787938361128c2bc21ed896dd4523651b59cb420 (diff) |
support parameter annotations in deftype/record
Diffstat (limited to 'src/clj')
-rw-r--r-- | src/clj/clojure/core.clj | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 48da4fc3..7ce2573e 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -3843,16 +3843,21 @@ (add-annotation av (name k) v)) (add-annotation av "value" v))) -(defn- add-annotations [visitor m] - (doseq [[k v] m] - (when (symbol? k) - (when-let [c (resolve k)] - (when (is-annotation? c) - ;this is known duck/reflective as no common base of ASM Visitors - (let [av (.visitAnnotation visitor (descriptor c) - (is-runtime-annotation? c))] - (process-annotation av v) - (.visitEnd av))))))) +(defn- add-annotations + ([visitor m] (add-annotations visitor m nil)) + ([visitor m i] + (doseq [[k v] m] + (when (symbol? k) + (when-let [c (resolve k)] + (when (is-annotation? c) + ;this is known duck/reflective as no common base of ASM Visitors + (let [av (if i + (.visitParameterAnnotation visitor i (descriptor c) + (is-runtime-annotation? c)) + (.visitAnnotation visitor (descriptor c) + (is-runtime-annotation? c)))] + (process-annotation av v) + (.visitEnd av)))))))) (defn alter-var-root "Atomically alters the root binding of var v by applying f to its |