Skip to content

Commit f2c6747

Browse files
committed
feat: support for understands Class/n
1 parent d74645c commit f2c6747

File tree

1 file changed

+26
-14
lines changed
  • src/main/clojure/clojure/tools/analyzer/jvm

1 file changed

+26
-14
lines changed

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

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,36 @@
9393
(defmethod maybe-class String [s]
9494
(maybe-class (symbol s)))
9595

96+
(defn maybe-array-class-sym [x]
97+
(let [sname (name x)]
98+
(if-let [c (and (= (count sname) 1)
99+
(Character/isDigit (first sname))
100+
(namespace x))]
101+
(when-let [c (or (specials c)
102+
(maybe-class-from-string c))]
103+
(array-class (Integer/parseInt sname) c)))))
104+
96105
(defmethod maybe-class Symbol [sym]
97-
(when-not (namespace sym)
98-
(let [sname (name sym)
99-
snamec (count sname)]
100-
(if-let [base-type (and (.endsWith sname "<>")
101-
(maybe-class (subs sname 0 (- snamec 2))))]
102-
(array-class base-type)
103-
(if-let [ret (or (specials sname)
104-
(special-arrays sname))]
105-
ret
106-
(maybe-class-from-string sname))))))
106+
(let [sname (name sym)
107+
snamec (count sname)]
108+
(or (maybe-array-class-sym sym)
109+
(when-not (namespace sym)
110+
(if-let [base-type (and (.endsWith sname "<>")
111+
(maybe-class (subs sname 0 (- snamec 2))))]
112+
;; TODO: we're leaking into the syntax
113+
(array-class base-type)
114+
(if-let [ret (or (specials sname)
115+
(special-arrays sname))]
116+
ret
117+
(maybe-class-from-string sname)))))))
107118

108119
(defn maybe-class-literal [x]
109120
(cond
110-
(class? x) x
111-
(symbol? x) (and (not (namespace x))
112-
(maybe-class-from-string (name x)))
113-
(string? x) (maybe-class-from-string x)))
121+
(class? x) x
122+
(symbol? x) (or (maybe-array-class-sym x)
123+
(and (not (namespace x))
124+
(maybe-class-from-string (name x))))
125+
(string? x) (maybe-class-from-string x)))
114126

115127
(def primitive?
116128
"Returns non-nil if the argument represents a primitive Class other than Void"

0 commit comments

Comments
 (0)