Files
kotlin-fork/compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt
T
Ilya Chernikov 78ca733c38 FIR JS: add K2 variants of all other JS tests
except tests that are not possible to add without some modifications in
the test infra. See todos on the commented-out test declarations
2022-11-12 16:28:24 +01:00

25 lines
523 B
Kotlin
Vendored

// WITH_REFLECT
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
// FIR status: KotlinNothingValueException from create()
fun <T : A> create(modelClass: Class<T>): T {
return if (modelClass.isAssignableFrom(B::class.java)) {
createViewModel()
} else {
throw Exception()
}
}
@Suppress("UNCHECKED_CAST")
fun <T : A> createViewModel(): T {
return B() as T
}
open class A
class B : A()
fun box(): String {
val r = create(A::class.java)
return if (r is B) "OK" else "fail"
}