I think this happens if the class you cast to is an array with non-null elements, because the compiler can't guarantee the nullability of its elements. This will compile with an unchecked warning and will fail with a NPE at runtime:
val array = arrayOf(1,2, null)
(array as? Array<Int>)?.forEach(::println)