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

0 votes
in Errors by

user=> (set! *warn-on-reflection* true) true user=> (.contains [] 0) Reflection warning, NO_SOURCE_PATH:1:1 - call to method contains on clojure.lang.IPersistentVector can't be resolved (no such method). false user=> (.contains [1] 0) false user=> (.contains ^:foo [1] 0) Reflection warning, NO_SOURCE_PATH:1:1 - call to method contains on clojure.lang.IPersistentVector can't be resolved (no such method). false user=> (.contains [(inc 1)] 0) Reflection warning, NO_SOURCE_PATH:1:1 - call to method contains on clojure.lang.IPersistentVector can't be resolved (no such method). false

Even worse, type hinting doesn't get picked up :

user=> (.contains ^java.util.Collection [] 0) Reflection warning, NO_SOURCE_PATH:1:1 - call to method contains on clojure.lang.IPersistentVector can't be resolved (no such method). false user=> (.contains ^java.util.Collection [(inc 1)] 0) Reflection warning, NO_SOURCE_PATH:1:1 - call to method contains on clojure.lang.IPersistentVector can't be resolved (no such method). false user=> (.contains ^java.util.Collection (identity [(inc 1)]) 0) false

Similar issues apply to other literals

4 Answers

0 votes
by

Comment made by: alexmiller

This is not public api, does not seem worth messing with.

0 votes
by

Comment made by: bronsa

the clojure collections are at least documented to implement java.util.Collection, so the below example showcasing the same exact issue should be valid:

user=> (set! *warn-on-reflection* true) true user=> (.contains [] 0) Reflection warning, NO_SOURCE_PATH:1:1 - call to method contains on clojure.lang.IPersistentVector can't be resolved (no such method). false user=> (.contains [1] 0) false user=> (.contains ^:foo [1] 0) Reflection warning, NO_SOURCE_PATH:1:1 - call to method contains on clojure.lang.IPersistentVector can't be resolved (no such method). false user=> (.contains [(inc 1)] 0) Reflection warning, NO_SOURCE_PATH:1:1 - call to method contains on clojure.lang.IPersistentVector can't be resolved (no such method). false

0 votes
by

Comment made by: bronsa

I'm reopening this since the ticket is actually valid now that I've changed example -- and even worse than that I noticed that it's impossible to get rid of the reflection even with explicit type hinting

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1326 (reported by bronsa)
...