Skip to content

Commit

Permalink
fixes for latest clojure version
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurC committed May 2, 2024
1 parent 45f7881 commit a40ee67
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/hyperfiddle/electric/impl/expand.clj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,32 @@
(try (#'clojure.core/serialized-require sym) ; try bc it can be cljs file
(catch java.io.FileNotFoundException _))))

(defn macroexpand-clj [o] (serialized-require (ns-name *ns*)) (macroexpand-1 o))
(defn ?expand-clj-method-call [o]
(let [[s & args] o]
(if (clojure.lang.Compiler/namesStaticMember s)
(let [?class (-> s namespace symbol)]
(if (clojure.lang.Compiler$HostExpr/maybeClass ?class false)
(list* '. ?class (-> s name symbol) args)
o))
o)))

(defn macroexpand-clj [o]
(serialized-require (ns-name *ns*))
(let [o2 (macroexpand-1 o)]
(if (identical? o o2)
(?expand-clj-method-call o)
o2)))

;; - else if(namesStaticMember(sym))
;; - {
;; - Symbol target = Symbol.intern(sym.ns);
;; - Class c = HostExpr.maybeClass(target, false);
;; - if(c != null)
;; - {
;; - Symbol meth = Symbol.intern(sym.name);
;; - return preserveTag(form, RT.listStar(DOT, target, meth, form.next()));
;; - }
;; - }

(defn expand-referred-or-local-macros [o cljs-macro-env]
;; (:require [some.ns :refer [some-macro]])
Expand Down
8 changes: 8 additions & 0 deletions test/hyperfiddle/electric/impl/expand_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,11 @@
:ns 'hyperfiddle.electric.impl.expand-unloaded}
'(let [x 1]))))
(throw (ex-info "clj macroexpansion for unloaded ns fails" {}))))

#?(:clj
(tests
"clojure 1.12 macroexpansion regression on class/method calls"
(all '(clojure.lang.PersistentArrayMap/createAsIfByAssoc nil)) := '(. clojure.lang.PersistentArrayMap createAsIfByAssoc nil)


))

0 comments on commit a40ee67

Please sign in to comment.