[Tests] Add test for KT-65197

^KT-65197
This commit is contained in:
Vladimir Sukharev
2024-01-30 14:00:59 +01:00
committed by Space Team
parent 9f8ea3e2e5
commit 112473f310
21 changed files with 150 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
// WITH_STDLIB
// KT-40613
// IGNORE_BACKEND: NATIVE
// KT-65402
// IGNORE_BACKEND: JS, JS_IR, JS_IR_ES6
// KT-65403
// IGNORE_BACKEND: WASM
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()
}