Files
kotlin/compiler/testData/codegen/box/nullCheckOptimization/kt22410.kt
Dmitry Petrov 5e34f290ce Reified 'as?' produces nullable result
Previously, this was treated as a regular CHECKCAST, causing KT-22410.

 #Fixed KT-22410 Target versions 1.2.30
2018-01-26 10:22:59 +03:00

20 lines
317 B
Kotlin
Vendored

fun box(): String {
defineFunc<String>()
func(1)
return if (testedEquals) "OK" else "Fail"
}
var func: (Any) -> Unit = {}
var testedEquals = false
inline fun <reified T> defineFunc() {
func = {
val nullable = it as? T
if (nullable == null)
testedEquals = true
}
}