Files
kotlin-fork/compiler/testData/codegen/box/casts/objectToPrimitiveWithAssertion.kt
T
pyos dab693b075 Revert "JVM IR: Implement CHECK_NOT_NULL as a lowering"
This reverts commit dcd72b06d8.

Using a temporary variable has an effect on casts and GC.
2021-04-19 16:05:12 +02:00

9 lines
254 B
Kotlin
Vendored

// IGNORE_BACKEND: JS, JS_IR, WASM
@Suppress("UNCHECKED_CAST")
fun <T> f() = 1L as T
fun box(): String {
val x: Int = f()!! // T = Int?, but the cast succeeds because it's immediately upcasted to Number
return if (x == 1) "OK" else "fail: $x"
}