blob: f3da7603e04aece3425711307528cd8977a4add1 [file]
// FREE_COMPILER_ARGS: -Xbinary=genericSafeCasts=true
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
// WITH_STDLIB
fun <E> List<E>.addAnything(element: E) {
if (this is MutableList<E>) {
this.add(element)
}
}
fun box(): String {
val list = arrayListOf(1, 2)
list.addAnything("string")
try {
val x = list[2]
return "FAIL: $x"
} catch (e: ClassCastException) {
return "OK"
}
}