This is kind of an interesting case. From poking at it a bit, the {} is 
typed as a IPersistentMap, and IPM does NOT extend java.util.Map (although 
the implementations like PersistentArrayMap and PersistentHashMap do via 
APersistentMap).

I think the interesting question is why the type hint is not taking effect 
as you would expect that to work. That could be because {} is a constant 
empty map. That needs some more investigation and if you wanted to file a 
jira ticket, we could do so further.

One workaround to get you going for now is:

  (let [builder (DateTimeFormatterBuilder.)] 
    (.appendText builder ChronoField/YEAR ^java.util.Map (array-map)))




On Monday, May 16, 2016 at 7:15:35 AM UTC-5, 676c7...@gmail.com wrote:
>
> Hello,
>
> I am getting a reflection warning in Java interop and don’t understand
> why:
>
>     (import 'java.time.format.DateTimeFormatterBuilder
>             'java.time.temporal.ChronoField)
>
>     (set! *warn-on-reflection* true)
>
>     (let [builder (DateTimeFormatterBuilder.)]
>       (.appendText builder ChronoField/YEAR {}))
>     ; Reflection warning, ... - call to method appendText on 
> java.time.format.DateTimeFormatterBuilder can't be resolved (argument 
> types: java.time.temporal.ChronoField, clojure.lang.IPersistentMap).
>
> The method expects a java.util.Map, which {} implements, so this should
> resolve without problem. I have tried adding a type hint but it has no
> effect:
>
> (let [builder (DateTimeFormatterBuilder.)]
>   (.appendText builder ChronoField/YEAR ^java.util.Map {}))
>
> What is the best way to type-hint this properly?
>
> Thank you,
>
>
> -- 
> David
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to