funcool / clojure.jdbc

JDBC library for Clojure
http://funcool.github.io/clojure.jdbc/latest/
Apache License 2.0
105 stars 26 forks source link

reflection warnings #34

Closed tomconnors closed 7 years ago

tomconnors commented 7 years ago

With version 0.9.0, the following code gets a reflection warning:

(with-open [conn (jdbc/connection my-connection-pool)]
   (do-anything conn))

I'm able to remove the reflection warnings by changing that to:

(with-open [^java.io.Closeable conn (jdbc/connection my-connection-pool)]
   (do-anything conn))

But I'm unsure whether there's a more specific type I should be hinting. If that's the right hint, would you take a PR adding the type hint to the implementation of jdbc/connection?

niwinz commented 7 years ago

Hmm, seems like this should be hinted on the user side, we can't type hint the connection function with Closeable. However your code is correct, in this concrete situation the connection behaves as closable so the hint is correct.