Files
kotlin-fork/compiler/testData/codegen/bytecodeText/nullCheckOptimization/noNullCheckAfterCast.kt
T
Dmitry Petrov 1e5fc1c3aa JVM_IR KT-27427 use checkNotNull with message in checked casts
This would prevent extra branching in 'as <not-null-type>', which
usually would not be covered.
2021-12-30 13:41:21 +03:00

34 lines
439 B
Kotlin
Vendored

// KT-27427
interface A {
fun foo()
}
class B : A {
override fun foo() {
}
}
fun test1() {
val b = B()
(b as A).foo()
}
fun test2() {
val b = getB()
(b as A).foo()
}
fun test3() {
val b = getB()
b.foo()
}
fun getB(): B = B()
// JVM_TEMPLATES
// 1 IFNONNULL
// JVM_IR_TEMPLATES
// 0 IFNONNULL
// 1 INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkNotNull \(Ljava/lang/Object;Ljava/lang/String;\)V