Permalink
Browse files

CLJS-948: simplify macro usage

When using or requiring a namespace that itself requires a macro file
of the same name implicitly require the library's macros using the
same provided spec information.
  • Loading branch information...
swannodette committed Feb 1, 2015
1 parent 05d0209 commit 28e6070691e89f5fe35ae8f8a196ae1048fbf07d
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/clj/cljs/analyzer.clj
View
@@ -1224,6 +1224,13 @@
{:import import-map
:require import-map}))
(defn macro-autoload-ns? [form]
(let [ns (if (sequential? form) (first form) form)
{:keys [use-macros require-macros]}
(get-in @env/*compiler* [::namespaces ns])]
(or (contains? use-macros ns)
(contains? require-macros ns))))
(defn desugar-ns-specs [args]
(let [{:keys [require] :as indexed}
(->> args
@@ -1239,7 +1246,9 @@
to-macro-specs
(fn [specs]
(->> specs
(filter #(and (sequential? %) (some sugar-keys %)))
(filter #(or (and (sequential? %)
(some sugar-keys %))
(macro-autoload-ns? %)))
(map #(->> % (remove-from-spec #{:include-macros})
(remove-from-spec #{:refer})
(map (fn [x] (if (= x :refer-macros) :refer x)))))))

0 comments on commit 28e6070

Please sign in to comment.