Skip to content

Instantly share code, notes, and snippets.

@cemerick
Created April 30, 2010 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemerick/9d1769237b312eb49723 to your computer and use it in GitHub Desktop.
Save cemerick/9d1769237b312eb49723 to your computer and use it in GitHub Desktop.
From 7af28ec38eaf7e7f545faaa17add27243203f890 Mon Sep 17 00:00:00 2001
From: Chas Emerick <cemerick@snowtide.com>
Date: Fri, 30 Apr 2010 14:26:46 -0400
Subject: [PATCH] Use .valAt for keyword access of defrecord fields with the same name as no-arg methods
---
src/clj/clojure/core_deftype.clj | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/clj/clojure/core_deftype.clj b/src/clj/clojure/core_deftype.clj
index 58a181c..e34748a 100644
--- a/src/clj/clojure/core_deftype.clj
+++ b/src/clj/clojure/core_deftype.clj
@@ -167,7 +167,12 @@
base-fields)
(get ~'__extmap ~'k ~'else)))
`(getLookupThunk [~'this ~'k]
- (let [~'gclass (class ~'this)]
+ (let [~'gclass (class ~'this)
+ no-arg-method-names# (->> ~'gclass .getMethods
+ (filter #(== 0 (-> % .getParameterTypes count)))
+ (map #(.getName %))
+ set)
+ ~'k (when-not (no-arg-method-names# (name ~'k)) ~'k)]
(case ~'k
~@(let [hinted-target (with-meta 'gtarget {:tag tagname})]
(mapcat
--
1.6.2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment