Files
pyos d66be3f82d FIR CFG: do not assume all arguments to inline funs are called in place
Only values for non-noinline, non-crossinline, functional type
parameters qualify.
2022-12-08 10:19:32 +00:00

39 lines
827 B
Kotlin
Vendored

inline fun callsInPlaceInline(x: () -> Unit) = x()
<!NOTHING_TO_INLINE!>inline<!> fun <T> any(x: T) = x
<!NOTHING_TO_INLINE!>inline<!> fun noinline(noinline x: () -> Unit) = x
inline fun crossinline(crossinline x: () -> Unit) = { x() }
fun testInline() {
var x: String? = null
callsInPlaceInline { x = null }
x = ""
x.length // ok
}
fun testGeneric() {
var x: String? = ""
val lambda = any { x = null }
x = ""
lambda()
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // bad
}
fun testNoinline() {
var x: String? = ""
val lambda = noinline { x = null }
x = ""
lambda()
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // bad
}
fun testCrossinline() {
var x: String? = ""
val lambda = crossinline { x = null }
x = ""
lambda()
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // bad
}