blob: 6bee071d9ac1905634cf83a1f615b3db6c25037b [file]
// FREE_COMPILER_ARGS: -Xbinary=genericSafeCasts=true
// WITH_STDLIB
// KT-65402
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
private fun <T> some(): T =
Some1() as T
private class Some1
private class Some2(private val s: String) {
fun foo(): String = "Some2: $s"
}
fun box(): String {
val some2 = try {
some<Some2>()
} catch(cce: ClassCastException) {
val message = cce.toString()
return if (Regex(".*Some1( cannot be cast)? to .*Some2.*").matches(message))
"OK"
else
message
} catch (t: Throwable) {
return t.toString()
}
return some2.foo()
}