From 9c9b19af266c754eeee59bf83242df822b2d6145 Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Mon, 27 Jun 2016 17:32:02 -0400 Subject: [PATCH] fix error when using specter with aot --- CHANGES.md | 1 + src/clj/com/rpl/specter/macros.clj | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index e602a40..fa1e9fd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,7 @@ transformations with `transform` one after another when the transformations shar * Bug fix: END, BEGINNING, FIRST, LAST, and MAP-VALS now work properly on nil * Bug fix: ALL and MAP-VALS now maintain the comparator of sorted maps * Bug fix: Using value collection along with `setval` no longer throws exception +* Bug fix: Fix error when trying to use Specter along with AOT compilation ## 0.11.2 * Renamed com.rpl.specter.transient namespace to com.rpl.specter.transients to eliminate ClojureScript compiler warning about reserved keyword diff --git a/src/clj/com/rpl/specter/macros.clj b/src/clj/com/rpl/specter/macros.clj index 4322572..7fb4f46 100644 --- a/src/clj/com/rpl/specter/macros.clj +++ b/src/clj/com/rpl/specter/macros.clj @@ -536,7 +536,16 @@ info-sym (gensym "info") get-cache-code (if (= platform :clj) - `(i/get-cell ~cache-sym) + `(try (i/get-cell ~cache-sym) + (catch ClassCastException e# + (if (bound? (var ~cache-sym)) + (throw e#) + (do + (alter-var-root + (var ~cache-sym) + (fn [_#] (i/mutable-cell))) + nil + )))) cache-sym ) add-cache-code (if (= platform :clj)