filterIsInstance shouldn't state that is performing a unsafe cast?

Next statement throws a ClassCastException:

val foo = listOf(listOf("hello")).filterIsInstance<List<Int>>().first().first()

There are no compile errors or warnings, nor is there anything in the Kotlin documentation that explicitly mentions this behavior. I understand the type erasure feature and that filterIsInstance is simply performing an is check. However, shouldn’t this behavior be documented?

1 Like

I believed it’s mentioned here:

1 Like