Is there a different way of specifying the followi...
# android
j
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>) {}
u
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?
j
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?
u
But why exactly do you need the
@param:
use-site target? It makes no sense there because
Int
is not a function parameter, which is the only place where
@param:
is allowed. You probably mean
Map<String, @RawRes Int>
, without
@param:
, 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
j
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
p
Even if it has no effect on the compiler, its clear what this int means when reading the code