In this example
(defrecord x [y])
(defn b [x] (.getBytes ^String x))
The compiler fails to resolve .getBytes. It emits reflection code, saying x
is a class. It is resolved by deleting the defrecord, or renaming the
parameter.
Is this expected, or documented? Are there other cases like this?
What version of Clojure/Script are you using? This works fine for me on
Clojure 1.10.1.
On Wed, Aug 28, 2019 at 4:08 PM Brian Craft wrote:
> In this example
>
> (defrecord x [y])
>
> (defn b [x] (.getBytes ^String x))
>
>
> The compiler fails to resolve .getBytes. It emits reflection code, sayin
I tried it on Clojure 1.10.1 and if I first did (set! *warn-on-reflection*
true) the defn of b did give a reflection warning if you first did the
defrecord, but not without the defrecord.
Andy
On Wed, Aug 28, 2019 at 6:35 PM Sean Corfield wrote:
> What version of Clojure/Script are you using? T
With the presence of the record definition, the macro expander seems to
expand
(.getBytes ^String x)
into
(. ^Class (clojure.core/identity ^java.lang.String x) getBytes)
and which causes reflection call.
(BTW this "tricky" expansion is done to distinguish instance method calls
on Class object