6fc0de39c2
This gives us more precise type information and can enable backend optimizations. This was motivated by when expressions not compiled to table switches in the JVM_IR backend. Fixed KT-36845.
35 lines
664 B
Plaintext
Vendored
35 lines
664 B
Plaintext
Vendored
fun test1(x: String?): Int {
|
|
return when {
|
|
EQEQ(arg0 = x, arg1 = null) -> 0
|
|
else -> x.<get-length>()
|
|
}
|
|
}
|
|
|
|
fun <T : CharSequence?> test2(x: T): Int {
|
|
return when {
|
|
EQEQ(arg0 = x, arg1 = null) -> 0
|
|
else -> x.<get-length>()
|
|
}
|
|
}
|
|
|
|
inline fun <reified T : CharSequence?> test3(x: Any): Int {
|
|
return when {
|
|
x !is T -> 0
|
|
else -> x /*as T */.<get-length>()
|
|
}
|
|
}
|
|
|
|
inline fun <reified T : CharSequence> test4(x: Any?): Int {
|
|
return when {
|
|
x !is T -> 0
|
|
else -> x /*as T */.<get-length>()
|
|
}
|
|
}
|
|
|
|
fun <T : S?, S : Any?> test5(x: T, fn: Function1<S, Unit>) {
|
|
when {
|
|
EQEQ(arg0 = x, arg1 = null).not() -> fn.invoke(p1 = x)
|
|
}
|
|
}
|
|
|