Skip to content

Commit 2af2556

Browse files
More analyzer opt
1 parent 86bfd84 commit 2af2556

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

typed/clj.analyzer/src/typed/clj/analyzer/utils.cljc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -268,21 +268,22 @@
268268

269269
:default
270270

271-
(defn ^Class unbox
272-
"If the argument is a Class with a primitive equivalent, returns that,
271+
(do (def ^:private classes-with-primitives
272+
{Integer Integer/TYPE,
273+
Long Long/TYPE,
274+
Float Float/TYPE,
275+
Short Short/TYPE,
276+
Boolean Boolean/TYPE,
277+
Byte Byte/TYPE,
278+
Character Character/TYPE,
279+
Double Double/TYPE,
280+
Void Void/TYPE})
281+
282+
(defn ^Class unbox
283+
"If the argument is a Class with a primitive equivalent, returns that,
273284
otherwise returns the argument"
274-
[c]
275-
({Integer Integer/TYPE,
276-
Long Long/TYPE,
277-
Float Float/TYPE,
278-
Short Short/TYPE,
279-
Boolean Boolean/TYPE,
280-
Byte Byte/TYPE,
281-
Character Character/TYPE,
282-
Double Double/TYPE,
283-
Void Void/TYPE}
284-
c c))
285-
)
285+
[c]
286+
(classes-with-primitives c c))))
286287

287288
(defn numeric?
288289
"Returns true if the given class is numeric"

typed/cljc.analyzer/src/typed/cljc/analyzer/utils.cljc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,8 @@
203203

204204
(defn- -source-info-into-transient!
205205
"Like `-source-info`, but returns a raw transient."
206-
[x env dest]
207-
(let [t (->> dest
208-
(source-info-into-transient! env)
209-
(source-info-into-transient! (meta x)))]
206+
[x dest]
207+
(let [t (source-info-into-transient! (meta x) dest)]
210208
(if-let [file (let [file #?(:cljs cljs-ana/*cljs-file*
211209
:default *file*)]
212210
(and (not= file "NO_SOURCE_FILE")
@@ -217,7 +215,12 @@
217215
(defn -source-info
218216
"Returns the source-info of x"
219217
([x env] (-source-info x env {}))
220-
([x env base] (persistent! (-source-info-into-transient! x env (transient base)))))
218+
([x env base]
219+
(persistent! (if (identical? env base)
220+
(-source-info-into-transient! x (transient base))
221+
(->> (transient base)
222+
(source-info-into-transient! env)
223+
(-source-info-into-transient! x))))))
221224

222225
(defn const-val
223226
"Returns the value of a constant node (either :quote or :const)"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy