Skip to content

Commit

Permalink
feat: array-class for multi-dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronsa committed Oct 18, 2024
1 parent 082c814 commit d74645c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/clojure/clojure/tools/analyzer/jvm/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@
"Takes a Symbol, String or Class and tires to resolve to a matching Class"
class)

(defn array-class [element-type]
(RT/classForName
(str "[" (-> element-type
maybe-class
Type/getType
.getDescriptor
(.replace \/ \.)))))
(defn array-class
([element-type] (array-class 1 element-type))
([n element-type]
(RT/classForName
(str (apply str (repeat n"["))
(-> element-type
maybe-class
Type/getType
.getDescriptor
(.replace \/ \.))))))

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

0 comments on commit d74645c

Please sign in to comment.