Skip to content

Commit 63fce24

Browse files
committed
- reify should not emit basis static method
- reify should set meta to nil if no actual meta
1 parent a5f824c commit 63fce24

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main/clojure/cljs/core.cljc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@
13651365
[& impls]
13661366
(core/let [t (with-meta
13671367
(gensym
1368-
(core/str "t_"
1368+
(core/str "t_reify_"
13691369
(string/replace (core/str (munge ana/*cljs-ns*)) "." "$")))
13701370
{:anonymous true})
13711371
meta-sym (gensym "meta")
@@ -1382,7 +1382,11 @@
13821382
IMeta
13831383
(~'-meta [~this-sym] ~meta-sym)
13841384
~@impls))
1385-
(new ~t ~@locals ~(ana/elide-reader-meta (meta &form))))))
1385+
(new ~t ~@locals
1386+
;; if the form meta is empty, emit nil
1387+
~(let [form-meta (ana/elide-reader-meta (meta &form))]
1388+
(when-not (empty? form-meta)
1389+
form-meta))))))
13861390

13871391
(core/defmacro specify!
13881392
"Identical to reify but mutates its first argument."
@@ -1799,7 +1803,9 @@
17991803
(deftype* ~t ~fields ~pmasks
18001804
~(if (seq impls)
18011805
`(extend-type ~t ~@(dt->et t impls fields))))
1802-
(set! (.-getBasis ~t) (fn [] '[~@fields]))
1806+
;; don't emit static basis method w/ reify
1807+
~@(when-not (.startsWith (name t) "t_reify")
1808+
[`(set! (.-getBasis ~t) (fn [] '[~@fields]))])
18031809
(set! (.-cljs$lang$type ~t) true)
18041810
(set! (.-cljs$lang$ctorStr ~t) ~(core/str r))
18051811
(set! (.-cljs$lang$ctorPrWriter ~t) (fn [this# writer# opt#] (-write writer# ~(core/str r))))

0 commit comments

Comments
 (0)