Extend Expand to APersistentMap on JVM - #794
Merged
Merged
Conversation
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
marked this pull request as ready for review
September 4, 2026 13:58
opqdonut
requested changes
Sep 15, 2026
|
|
||
| #?(:clj clojure.lang.PersistentHashMap | ||
| :cljs cljs.core.PersistentHashMap) | ||
| #?(:cljs cljs.core.PersistentHashMap) |
Member
There was a problem hiding this comment.
hmm: how is this syntactically valid in the clj case? shouldn't the next line be inside the #? guard as well?
Contributor
Author
There was a problem hiding this comment.
i won't pretend to understand the details of the #?(:clj and #?(:cljs) conditionals, but i made a few tweaks: fb92a9f
should be easier to read, and added a test case for good measure.
let me know what you think!!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
reitit.core/Expandtoclojure.lang.APersistentMapinstead of the concretePersistentArrayMap/PersistentHashMapclasses.Behavior for stock Clojure maps is unchanged (
expandstill returnsthis). Protocol dispatch continues to cache per concrete class after first resolve.This keeps route-data map expansion working for any
APersistentMapsubclass (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
APersistentMapbut notPersistentArrayMap/PersistentHashMap. Extending those concrete classes means Cloffle map literals missExpand; targetingAPersistentMapfixes that without changing stock Clojure behavior.We use
reititas part of our compatibility tests with Clojure, and we maintain this patch forreititinternally. This PR would help us avoid that, without any performance impact on reitit itself.