Skip to content

Commit 37c768f

Browse files
More analyzer opt
1 parent 86bfd84 commit 37c768f

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
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: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,32 @@
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)))]
210-
(if-let [file (let [file #?(:cljs cljs-ana/*cljs-file*
211-
:default *file*)]
212-
(and (not= file "NO_SOURCE_FILE")
213-
file))]
214-
(assoc! t :file file)
215-
t)))
206+
([x dest]
207+
(let [t (source-info-into-transient! (meta x) dest)]
208+
(if-let [file (let [file #?(:cljs cljs-ana/*cljs-file*
209+
:default *file*)]
210+
(and (not= file "NO_SOURCE_FILE")
211+
file))]
212+
(assoc! t :file file)
213+
t)))
214+
([x env dest]
215+
(let [t (->> dest
216+
(source-info-into-transient! env)
217+
(source-info-into-transient! (meta x)))]
218+
(if-let [file (let [file #?(:cljs cljs-ana/*cljs-file*
219+
:default *file*)]
220+
(and (not= file "NO_SOURCE_FILE")
221+
file))]
222+
(assoc! t :file file)
223+
t))))
216224

217225
(defn -source-info
218226
"Returns the source-info of x"
219227
([x env] (-source-info x env {}))
220-
([x env base] (persistent! (-source-info-into-transient! x env (transient base)))))
228+
([x env base]
229+
(if (identical? env base)
230+
(persistent! (-source-info-into-transient! x (transient base)))
231+
(persistent! (-source-info-into-transient! x env (transient base))))))
221232

222233
(defn const-val
223234
"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