Why isn't the type parameter inferred in the follo...
# compiler
e
Why isn't the type parameter inferred in the following case, i.e. why can't I just use
FooAnnotation(String::class)
? Seems to only be an issue with annotations
Copy code
annotation class FooAnnotation<K : Any>(val key: KClass<in K>)

@FooAnnotation<String>(String::class)
object Foo
h
Are you sure Java/JVM even supports annotations with generics?
e
Kotlin does but Java doesn't
in any case, you're looking at https://youtrack.jetbrains.com/issue/KT-26637
thank you color 1
a
Are you sure you even need a type parameter there? I would either go with a type param or a kclass, but I don’t really know when you would need both
e
Haven't 100% thought it through, but I'd like to use it as a hint for KSP