Skip to content

Commit 0876743

Browse files
committed
correctly emit internal-methods on deftypes too
1 parent 0ee39d7 commit 0876743

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

src/main/clojure/clojure/tools/emitter/jvm/emit.clj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@
924924

925925
;; addAnnotations
926926
(defmethod -emit :method
927-
[{:keys [this params name bridges tag fixed-arity variadic? body env]}
927+
[{:keys [this params name bridges tag fixed-arity variadic? body env internal-methods]}
928928
{:keys [class] :as frame}]
929929

930930
(let [method-name name
@@ -945,7 +945,8 @@
945945
:o-tag (or (:tag body) Object))
946946
(assoc frame
947947
:loop-label loop-label
948-
:loop-locals params))
948+
:loop-locals params
949+
:params params))
949950
[:mark ~end-label]
950951
[:return-value]
951952
[:end-method]]]
@@ -964,7 +965,9 @@
964965
[:load-args]
965966
[:invoke-virtual ~@target]
966967
[:return-value]
967-
[:end-method]]}))]))
968+
[:end-method]]}))
969+
~@(when internal-methods
970+
(emit-internal-methods internal-methods (assoc frame :params params)))]))
968971

969972
(defmethod -emit :local
970973
[{:keys [to-clear? local name tag o-tag arg-id]}

src/main/clojure/clojure/tools/emitter/passes/jvm/collect_internal_methods.clj

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
{:pass-info {:walk :none :depends #{} :compiler true}} ;; ensure it's run last
1616
[ast]
1717
(case (:op ast)
18-
:fn-method
19-
(binding [*internal-methods* (atom [])]
20-
(let [ast (update-children ast collect-internal-methods)]
21-
(merge ast
22-
(when-let [m (seq @*internal-methods*)]
23-
{:internal-methods m}))))
18+
(:method :fn-method)
19+
(binding [*internal-methods* (atom [])]
20+
(let [ast (update-children ast collect-internal-methods)]
21+
(merge ast
22+
(when-let [m (seq @*internal-methods*)]
23+
{:internal-methods m}))))
2424

25-
(:try :loop)
26-
(let [ast (update-children (assoc ast :internal-method-name
27-
(or (:loop-id ast) (gensym "try__")))
28-
collect-internal-methods)]
29-
(swap! *internal-methods* conj ast)
30-
ast)
25+
(:try :loop)
26+
(let [ast (update-children (assoc ast :internal-method-name
27+
(or (:loop-id ast) (gensym "try__")))
28+
collect-internal-methods)]
29+
(swap! *internal-methods* conj ast)
30+
ast)
3131

32-
(update-children ast collect-internal-methods)))
32+
(update-children ast collect-internal-methods)))

0 commit comments

Comments
 (0)