Skip to content

Commit 46dcd22

Browse files
mfikesdnolen
authored and
dnolen
committed
CLJS-1928: Self-host: Macro namespace alias in keyword
Also consult macros namespaces in analysis cache when setting up alias map.
1 parent 3aa1951 commit 46dcd22

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/main/cljs/cljs/js.cljs

+4-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@
177177

178178
(defn- current-alias-map
179179
[]
180-
(get-in @env/*compiler* [:cljs.analyzer/namespaces ana/*cljs-ns* :requires]))
180+
(->> (merge (get-in @env/*compiler* [::ana/namespaces ana/*cljs-ns* :requires])
181+
(get-in @env/*compiler* [::ana/namespaces ana/*cljs-ns* :require-macros]))
182+
(remove (fn [[k v]] (= k v)))
183+
(into {})))
181184

182185
;; -----------------------------------------------------------------------------
183186
;; Analyze

src/test/cljs/cljs/keyword_macros.clj

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(ns cljs.keyword-macros)
2+
3+
(defmacro add
4+
[a b]
5+
`(+ ~a ~b))

src/test/cljs/cljs/keyword_test.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
;; You must not remove this notice, or any other, from this software.
88

99
(ns cljs.keyword-test
10-
(:require-macros [clojure.core :as cc]
10+
(:require-macros [cljs.keyword-macros :as macros]
1111
[cljs.test :refer [deftest is]])
1212
(:require [cljs.keyword-other :as other]
1313
[cljs.test]))
1414

1515
(deftest test-keyword
1616
(is (= ::bar :cljs.keyword-test/bar))
1717
(is (= ::other/foo :cljs.keyword-other/foo))
18-
(is (= ::cc/foo :clojure.core/foo)))
18+
(is (= ::macros/foo :cljs.keyword-macros/foo)))

src/test/self/self_parity/test.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@
283283
[foo.ns-shadow-test]
284284
[cljs.top-level]
285285
[cljs.reducers-test]
286-
#_[cljs.keyword-test]
286+
[cljs.keyword-test]
287287
[cljs.import-test]
288288
[cljs.ns-test.foo]
289289
[cljs.pprint]
@@ -318,7 +318,7 @@
318318
'cljs.binding-test
319319
'cljs.macro-test
320320
'cljs.top-level
321-
#_'cljs.keyword-test
321+
'cljs.keyword-test
322322
#_'cljs.ns-test
323323
'cljs.ns-test.foo
324324
'foo.ns-shadow-test

0 commit comments

Comments
 (0)