When I switch (deftype ... into (deftype-only
my working code starts to throw:
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: toString in this context, compiling:(db/start.clj:29:1)
at clojure.lang.Compiler.analyze (Compiler.java:6380)
midje 1.5.0, clojure 1.5.1, java 7, ubuntu.
The cause is this snippet at the bottom of my deftype is:
(toString ; for debugging...
I find this snippet helpful and don't want to give it up.
Perhaps deftype-only needs a little tweak to support fns outside of the original defprotocol?
I think I've replicated something similar here:
git clone -b issue-198 firstname.lastname@example.org:josephwilk/Midje.git && cd Midje && lein midje
Specially with the example:
(deftype-openly LongerRecord [a b c]
(add-fields [this] (+ a b c))
(add-fields-and [this x]
(+ (add-fields this) x))
I see what's going on. Working on it.
Will be fixed in 1.5.1, which I might finish up today.
Fixed #198: deftype-openly and Java classes