IntelliJ gives me a warning on the following:
fun main(args: Array<String>) {
val foo: Any = arrayOf("test")
val bar = foo as Array<String>
}
It says it’s an unchecked cast. It does not give me this with Array<*>
. I am aware with type erasure on the JVM that this is understandable with most generics, but with arrays even though Kotlin treats the element type as generic, the JVM does not and "(String[]) foo
" is perfectly valid.
Is this by intention? How should I mimic a totally normal specific array type cast in Kotlin without getting a warning?