At the moment, I'm trying to remove a reflection warning, namely call to java.util.HashSet ctor can't be resolved.. I'm doing this:
A moment, whilst I get the right clojure...
(->> results
(map build-credential-id)
(HashSet/new))I've tried type hinting all over the place, but to no avail (even type hinting the return type of build-credential-id (which is returning a Java class)
The only way I could remove the type hint is this:
(let [hashset (HashSet.)]
(->> results
(map build-credential-id)
(.addAll hashset))
hashset))You could use param-tags on HashSet/new - that makes it explicit
(^[Collection] HashSet/new)
Not sure if thatβs the right type but whatever that should be
That will either work without reflection or throw, never reflects
Hmm, you know I did try that, let me try again
(I reviewed the interop page before coming here and tried the Clojure 1.12 new thingie π )
That seems to make the clojure compiler complain:
(->> results
(map build-credential-id)
([^PublicKeyCredentialDescriptor] HashSet/new))Unmatched delimiter: ]
sorry, my mistake, had the caret in the wrong place π
Ended up with this:
; (err) Syntax error (IllegalArgumentException) compiling HashSet/new at (src/repository.clj:101:18).
; (err) Error - param-tags [com.yubico.webauthn.data.PublicKeyCredentialDescriptor] insufficient to resolve constructor in class java.util.HashSetFrom
(->> results
(map build-credential-id)
(^[PublicKeyCredentialDescriptor] HashSet/new)))Oooh, I see, if I put it like this ^[Collection] it works
Wunderbar. Thank you! π I got there in the end, with a bit of hinting, ta π
Working without reflection warning:
(->> results
(map build-credential-id)
(^[Collection] HashSet/new))).
but that feels very wrong
Any hints (pun intended! π )?