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

0 votes
ago in Clojure by

When calling a method on an instance of a Java class that takes a Collection<? extends Something> as the argument, I've tried the following:

(.theMethod ^SomeClass inst ^Collection [thing1 thing2])

Unfortunately, when I'm using lein check this gives me a reflection warning of:

call to method theMethod on example.SomeClass can't be resolved (argument types: clojure.lang.IPersistentVector).

I can fix this by binding it to a symbol with a type hint:

(let [^Collection things [thing1 thing2]]
  (.theMethod ^SomeClass inst things))

What is going on that the literal vector can't be type-hinted in place?

Please log in or register to answer this question.

...