clj-2568-1 checks if the form was a clojure.lang.IObj and if the result transformed with f is also a clojure.lang.IObj. If so, it copies the metadata from original to transformed.
clj-2568-2 inlines the cond form of the extra var/function that was introduced
clj-2568-3 allows the function arg f in postwalk to update the restored metadata (attach additional data, remove metadata, etc).
There might be an optimization possible in the anonymous function used in clj-2568-3 which can be implemented once there is agreement on the chosen direction.
clj-2568-2 inlines the cond form.
Something to consider is whether existing code modifies coll metadata during walk and will thus be broken by this change.
Uploaded patch clj-2568-3 where function f gets control over the final metadata. It sees the restored metadata and can then make decisions as to leave it there, update it, remove it, etc.
I had to update the test in readers.cljc since it was accidentally testing the non-preservation of metadata by comparing two nil items.
Notice that this bug also impact other functions in clojure.walk namespace (e.g clojure.walk/keywordize-keys)
Should we create another ticket for that?
: patch CLJS-2568-3 should also fix other usages of clojure.walk: