user=> (ann-record X [x :- Number])
user=> (defrecord X [x])
user=> (cf (assoc (X. 3) :x 3) X)
0.2.7 thought this should be (Map Any Any)
0.2.9 just thinks you can't do it at all
but it should pass.
Had a quick look
So looks like result of (X. 3) is being instantiated as an RClass rather than a DataType?
ann-record doesn't collect so need to wrap in a cf, just awkward
Global annotations are only collected during type checking.
I've tried to document this, but it seems to frequently trip people up. I've tried to ensure error messages based on missing annotations emphasise annotations must be provided via cf.
FWIW this might change in the future to defonce semantics.
There are a couple of other issues here.
1. The Java constructor X. type checked because datatype constructors are normal Java constructors that take Object. ann-record overrides constructors to take the field types.
A couple of approaches to fixing this:
warn if constructing an IType or IRecord that is unannotated
recommend avoiding the Java constructor in favour of the positional factory.
2. update-in is NYI, ticket here http://dev.clojure.org/jira/browse/CTYP-8
3. assoc might be too strict now. X implements IPersistentMap, so it should be able to assoc anything even if it is unannotated.
(cf (assoc (X. 3) :x 3)) should return (IPersistentMap Any Any).
Comment made by: julian
OK, assoc seems to be behaving itself under 0.2.11.
I should point out I'm using lein typed most of the time, so I'm not that familiar with the repl. I should probably confine myself to submitting scripts that lein typed can run...
This passed, and I think should pass:
(ann-record X [x :- Number])
(defrecord X [x])
(ann Z [-> X])
(defn Z  (assoc (X. 3) :x 3))
Ok. Also it would be helpful to include the actual type error or stacktrace in issues.