Skip to content

Commit 7a75568

Browse files
committed
avoid reflection
1 parent 1eb71b3 commit 7a75568

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

notebooks/qualified_methods.clj

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
(ns qualified-methods)
1+
(ns qualified-methods
2+
{:nextjournal.clerk/no-cache true})
23

34
(String/.length "foo")
45

@@ -10,12 +11,10 @@ Integer/parseInt ;; method value
1011

1112
String/CASE_INSENSITIVE_ORDER ;; field
1213

13-
;; TODO: get rid of reflection
1414
(String/new "dude") ;; constructor
1515

16-
String/new
16+
^[String] String/new
1717

18-
(map String/new ["dude"])
18+
(map ^[String] String/new ["dude"])
1919

2020
(map Integer/parseInt ["1" "2" "3"])
21-

tools-analyzer/nextjournal/clerk/clojure/tools/analyzer/jvm.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
(cond
137137
(= "new" opname)
138138
`(fn
139-
([x#] (new ~(symbol sym-ns) x#))
139+
([x#] (new ~(symbol sym-ns) x# d))
140140
;; TODO: analyze method and return properly expanded fn
141141
)
142142
(or (.startsWith opname ".")
@@ -669,5 +669,5 @@
669669

670670
(macroexpand-1 'clojure.lang.Compiler/LOADER)
671671
(macroexpand-1 '(String/new "foo"))
672-
(macroexpand-1 'String/new)
672+
673673
)

0 commit comments

Comments
 (0)