deftype instances with mutable fields cannot be compiled

Description

When evaluating or compiling an implementer of clojure.lang.IType, the compiler tries to reflectively access its fields. This fails, when a field is marked mutable (hence private):

For classes that don't implement IType, no such problem exists.

This problem commonly occurs, when implementing a tagged literal for a deftype with cached hash.

Environment

None

Activity

Show:
Alex Miller
December 31, 2016, 6:01 PM

Yeah, this is interesting. The compiler compiles a deftype into a call to the constructor with the current values of the fields, but mutable fields are not accessible. One alternative would be to provide some standard method to "read" the field set rather than relying on reflection. (Another would be changing the access modifiers for mutable fields but I think that's probably a non-starter.)

Assignee

Unassigned

Reporter

Herwig Hochleitner

Labels

Approval

Triaged

Patch

None

Priority

Major