ClassCastException using spec-infer

20 views
Skip to first unread message

Emlyn Corrin

unread,
Sep 6, 2016, 3:00:04 PM9/6/16
to core.typed
I've been trying out the automatic type/spec annotations, they are really cool!
The demo project worked well, but when I tried it on my own project, spec-infer gave the following error:

ClassCastException clojure.tools.reader.reader_types.IndexingPushbackReader cannot be cast to java.io.Closeable  clojure.core.typed.runtime-infer/ns-end-line/fn--24319 (runtime_infer.clj:2565)

which uses an IndexingPushBackReader in a with-open, but IndexingPushBackReader doesn't implement the Closeable interface.

Is this a bug in core.typed (it shouldn't use with-open?), or tools.reader (IndexingPushBackReader should implement Closeable?), or am I doing something wrong (maybe I have some conflicting deps)?

Thanks,
Emlyn

Ambrose Bonnaire-Sergeant

unread,
Sep 6, 2016, 4:03:02 PM9/6/16
to core.typed
Hi Emlyn,

IIRC, this is a recent tools.reader feature.

What's your `lein deps :tree` ?

Thanks,
Ambrose

Emlyn Corrin

unread,
Sep 7, 2016, 5:36:44 AM9/7/16
to core.typed
Hi Ambrose,

It's a rather large tree (maybe I should have started on a simpler project...), but the only tools.reader in there is [org.clojure/tools.reader "1.0.0-beta3"] via core.typed. However if I build the uberjar and look inside at clojure/tools/reader/reader_types.clj, the IndexingPushbackReader in there does not implement Closeable. I guess it must also be packaged in some other dependency, but I'm not sure how to go about finding which one... any ideas?

Thanks for your help,
Emlyn

Emlyn Corrin

unread,
Sep 7, 2016, 6:32:30 AM9/7/16
to core.typed
OK, I temporarily moved my local maven repository and reran 'lein deps'. Amongst everything it downloaded was tools.reader version 0.10.0 (plus the poms for a few other versions). That must be what's causing the problem, but I'm not sure why it's not showing up in 'lein deps :tree'. After some more investigation, it look like it's being pulled in by timbre (via encore) - I'll try excluding it from there and see how I get on.

Emlyn Corrin

unread,
Sep 7, 2016, 7:12:53 AM9/7/16
to core.typed
That helped - I was able to run spec-infer without errors, but then it didn't generate any specs (and runtime-infer just put in an empty (declare)). I think it might be because the code is aot compiled, would that prevent this working? 
Reply all
Reply to author
Forward
0 new messages