Skip to content

Commit d74645c

Browse files
committed
feat: array-class for multi-dimension
1 parent 082c814 commit d74645c

File tree

1 file changed

+10
-7
lines changed
  • src/main/clojure/clojure/tools/analyzer/jvm

1 file changed

+10
-7
lines changed

src/main/clojure/clojure/tools/analyzer/jvm/utils.clj

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,16 @@
6767
"Takes a Symbol, String or Class and tires to resolve to a matching Class"
6868
class)
6969

70-
(defn array-class [element-type]
71-
(RT/classForName
72-
(str "[" (-> element-type
73-
maybe-class
74-
Type/getType
75-
.getDescriptor
76-
(.replace \/ \.)))))
70+
(defn array-class
71+
([element-type] (array-class 1 element-type))
72+
([n element-type]
73+
(RT/classForName
74+
(str (apply str (repeat n"["))
75+
(-> element-type
76+
maybe-class
77+
Type/getType
78+
.getDescriptor
79+
(.replace \/ \.))))))
7780

7881
(defn maybe-class-from-string [^String s]
7982
(or (when-let [maybe-class (and (neg? (.indexOf s "."))

0 commit comments

Comments
 (0)