Hello everyone This code throws an internal compil...
# android
q
Hello everyone This code throws an internal compiler error at the time of building, I think it's a bug in Kotlin compiler ?
Copy code
@Composable
fun Reproduce() {
    var currentRoute: String? = null
    val expr = currentRoute != null && shouldShowBottomNav(currentRoute)
}

@Composable
fun shouldShowBottomNav(currentRoute: String): Boolean {
    return true
}
It only happens when the functions are annotated with
@Composable
so probably related to Jetpack compose I was only able to reproduce the error on the same project though, it does not really happen when I start a new project and try the same. I have tried: Clean building, invalidating IDE cache, deleting files under
~/.android
and
~/.gradle
to clear those caches but it always gives me same result Here is the traceback from android studio: https://pastebin.com/i5BkEDBU
c
Try in #compose
l
why area you annotating these functions with @Composable?
p
To demonstrate the bug, it's a sscce
d
It’s not a bug, those aren’t composables.
Composable functions are the fundamental building blocks of an application built with Compose.
Composable can be applied to a function or lambda to indicate that the function/lambda can be used as part of a composition to describe a transformation from application data into a tree or hierarchy.
Annotating a function or expression with Composable changes the type of that function or expression. For example, Composable functions can only ever be called from within another Composable function. A useful mental model for Composable functions is that an implicit “composable context” is passed into a Composable function, and is done so implicitly when it is called from within another Composable function. This “context” can be used to store information from previous executions of the function that happened at the same logical point of the tree.
What you’re seeing is the compiler properly throwing errors back that the two methods that you are providing aren’t composables and are failing at the IR level (compiling for JVM it seemss)
p
I don't agree. An internal crash is not good. And even though the code doesn't make sense I see no reason why it should fail with an internal compiler error
q
Just to clearify, the error occurred when I was building an actual Composable, I wrote the
Reproduce
function just to narrow down the source of the error
a
Backend Internal error
is always a bug in the compiler (compose compiler plugin here). Please file a bug if you can come up with a reproduction.
q
I was able to reproduce it in a simple project, filing a bug. Thanks for confirming!