Files
kotlin-fork/compiler/testData/codegen/box/jvm8/kt33054.kt
T
Mikhail Glukhikh 522eeae062 FIR2IR: standardize expression with smart cast conversion
To convert smart cast expression, now we just convert
original expression in standard way and wrap it with TYPE_OP.
Before this commit original expression was converted in different way,
that led to errors e.g. for this expression casting.
2020-02-25 12:13:42 +03:00

19 lines
575 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
open class A(val x: String) {
inline fun f() = if (this is C) this else A("O")
val y
inline get() = if (this is C) this else A("K")
}
class B : A("unused")
class C : A("unused")
// If the receiver is not CHECKCASTed to A when inlining, asm will infer Object
// for the result of `if` in `f` instead of A when generating stack maps because
// one branch has type A while the other has type B (a subtype of A, but asm
// does not know that). This would cause a JVM validation error.
fun box() = B().f().x + B().y.x