|
93 | 93 | (defmethod maybe-class String [s] |
94 | 94 | (maybe-class (symbol s))) |
95 | 95 |
|
| 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 | + |
96 | 105 | (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))))))) |
107 | 118 |
|
108 | 119 | (defn maybe-class-literal [x] |
109 | 120 | (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))) |
114 | 126 |
|
115 | 127 | (def primitive? |
116 | 128 | "Returns non-nil if the argument represents a primitive Class other than Void" |
|
0 commit comments