https://kotlinlang.org logo
#compose
Title
# compose
m

Margarita Volodina

01/17/2022, 3:22 PM
Hello everyone! Recently I’ve encountered a problem with kotlin inline functions using compose. Sample code:
Copy code
// there is any nullable computed condition possible
val test: Boolean? = null
test?.let {
    println("succeed")
} ?: run {
    println("error")
}
test?.let {
    Greeting("Android")
} ?: run {
    Greeting("ios")
}
For kotlinVersion=1.5.31, composeVersion=1.0.5 works as expected (
println("error")
,
Greeting("ios")
are called). For kotlinVersion=1.6.0 (and higher), composeVersion=1.1.0-rc01 composable function after
?:
is never called, even though
println("error")
is called. This behaviour could be easily reproduced for a new project from Android Studio wizard with default compose activity template. Does anyone have the same problem? Any ideas how to fix this for newer kotlin versions without rewriting code for using if-statements?
a

Adam Powell

01/17/2022, 3:32 PM
File it with the issue tracker and we'll get it fixed if there's a compiler bug still outstanding. In the meantime, use ifs.
🙏 1
m

Margarita Volodina

01/17/2022, 3:40 PM