Is there a different way of specifying the followi...
# android
Is there a different way of specifying the following in Kotlin 1.3? I'm getting
This annotation is not applicable to target 'undefined target' and use site target '@param'
errors now
Copy code
private fun foo(map: Map<String, @param:RawRes Int>) {}
This has been incorrect code since Kotlin 1.0 and AFAIK it did not affect the generated binary files in any way, so the fact that 1.3 started to report an error here is a good thing. What did you use this for?
It was being used to specify a map of keys to raw resource IDs when generating graphql requests. Is there any other solution besides inline classes that would help developers maintain type safety for the map?
But why exactly do you need the
use-site target? It makes no sense there because
is not a function parameter, which is the only place where
is allowed. You probably mean
Map<String, @RawRes Int>
, without
, but even then I'm curious how exactly do you rely on this annotation being there, because only the Kotlin reflection can read type annotations here and that support was also added only in 1.3
It's not my code. I just came across it when trying to update the app to 1.3. I'll let the author know that this isn't correct code
­čĹŹ 1
I assume the author was trying to leverage the android annotations to ensure the proper values were being added to the map
Even if it has no effect on the compiler, its clear what this int means when reading the code