Skip to content

Extend Expand to APersistentMap on JVM - #794

Open
The-Alchemist wants to merge 1 commit into
metosin:masterfrom
The-Alchemist:expand-apersistent-map
Open

Extend Expand to APersistentMap on JVM#794
The-Alchemist wants to merge 1 commit into
metosin:masterfrom
The-Alchemist:expand-apersistent-map

Conversation

@The-Alchemist

@The-Alchemist The-Alchemist commented Sep 4, 2026

Copy link
Copy Markdown

Summary

  • On JVM, extend reitit.core/Expand to clojure.lang.APersistentMap instead of the concrete PersistentArrayMap / PersistentHashMap classes.

Behavior for stock Clojure maps is unchanged (expand still returns this). Protocol dispatch continues to cache per concrete class after first resolve.

This keeps route-data map expansion working for any APersistentMap subclass (e.g. PersistentTreeMap, and alternate JVM Clojure runtimes that provide their own map implementations under that hierarchy), without requiring library-specific reader features.

Reason

Cloffle is a GraalVM/Truffle Clojure runtime with specialized map types that extend APersistentMap but not PersistentArrayMap / PersistentHashMap. Extending those concrete classes means Cloffle map literals miss Expand; targeting APersistentMap fixes that without changing stock Clojure behavior.

We use reitit as part of our compatibility tests with Clojure, and we maintain this patch for reitit internally. This PR would help us avoid that, without any performance impact on reitit itself.

Cover all APersistentMap subclasses (including alt-runtime map
impls) without naming concrete ArrayMap/HashMap classes. CLJS
keeps the existing concrete map extensions.

Signed-off-by: Karl Pietrzak <karl@medplum.com>
@The-Alchemist
The-Alchemist marked this pull request as ready for review September 4, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants