Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Clojure by

So I have this code

(defn- nanos->ms [elapsed-time]
  (double (/ elapsed-time 1000000)))

Even with (set! *warn-on-reflection* true) this compiles nicely.

But when I use tools.namespace.repl/refresh I get reflection warnings :

Reflection warning: file:....metrics.clj:6:3 - call to static method doubleCast on clojure.lang.RT cannot be resolved

My hypothesis is that I'm hitting the inlined version of double and that that is not type-hinted.

Would this be correct, and if so, how do I remove this reflection warning?

(defn double
  "Coerce to double"
  {:inline (fn  [x] `(. clojure.lang.RT (doubleCast ~x)))
   :added "1.0"}
  [^Number x] (clojure.lang.RT/doubleCast x))

2 Answers

0 votes
(defn- nanos->ms [elapsed-time]
  (/ elapsed-time 1000000.0))
While this solves the immediate problem, it doesn’t explain what I observe :)
0 votes

Can you set up some environment where I can repro?

I'll give it a shot and see what I can come up with.