We're updating the issue view to help you get more done. 

defcache needs to impl. iterator() to avoid Clojure 1.7 breakage

Description

After upgrading to Clojure 1.7 beta2 some of our code started failing, specifically attempts to use iterator() on (keys our-cache).

This is because post http://dev.clojure.org/jira/browse/CLJ-1499, calls to iterator on Seqables optimize by delegating to underlying collection iterator. defcache implements IPersistentMap but not iterator therefore:

1 2 3 user=> (.iterator (keys tc)) AbstractMethodError clojure.core.cache.TTLCache.iterator()Ljava/util/Iterator; clojure.lang.APersistentMap$KeySeq.iterator (APersistentMap.java:184)

Proposal: Make defcache implement Iterable (which is implied by implementing IPersistentMap). I implemented by invoking .iterator on the underlying base-field, however this brings up the issue of reflection (warnings then popped up). To fix, I applied meta to base-field to type-hint it to clojure.lang.IPersistentMap.

This seems implied by various checks for map? elsewhere but I am not certain this is the correct type hint. It could be as narrow as java.lang.Iterable to be sufficient, but it seemed better to make a broader statement here if that is correct.

Patch: ccache-41.patch

Environment

None

Status

Assignee

Fogus

Reporter

ColinC

Labels

None

Approval

Screened

Patch

Code and Test

Priority

Critical