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

robnik

02/12/2021, 6:43 PM
My project build.gradle file shows a warning:
Kotlin version that is used for building with Gradle (1.4.30) differs from the one bundled into the IDE plugin (1.4.21)
. It's on the line inside buildscript.dependencies: `classpath "org.jetbrains.kotlinkotlin gradle plugin$kotlin_version"`` . I thought we were supposed to use Kotlin 1.4.30 now? The Kotlin plugin doesn't seem to have an update available. I'm getting a much worse internal compiler error later, so I'm trying to sort out this warning first.
But this will not help resolve internal compiler error. Could you post compiler stacktrace here if you have one?
r

robnik

02/12/2021, 6:58 PM
Okay, let me see if I can attach a text file...
v

Vsevolod Ganin

02/12/2021, 7:10 PM
Looks bad
Copy code
Caused by: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call 'Column' into
public final fun invoke(paddingValues: androidx.compose.foundation.layout.PaddingValues, `$composer`: androidx.compose.runtime.Composer?, `$changed`: <http://kotlin.Int|kotlin.Int>): kotlin.Unit defined in com.mycompany.androidapp.`ComposableSingletons$AutoLoanAndInsuranceScreenKt`.<clinit>.<no name provided>
Probably should find minimal reproducer and file a bug
r

robnik

02/12/2021, 8:45 PM
@Vsevolod Ganin Bug with Kotlin/Jetbrains or Compose/Google? I do have a very simple demo. It doesn't like the
::method
refs...
Copy code
package co.demo

import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*

@Composable
fun Problem() {
    fun foo() { }
    Scaffold() { _ ->
        Column() {
            Button(onClick = ::foo) { }
        }
    }
}
Good news is that
{ foo() }
is a simple replacement.
v

Vsevolod Ganin

02/12/2021, 9:58 PM
Ah, great to hear. Actually I stumbled upon exactly this bug half a year back but never bothered that much to file a bug 🙂
Actually I tried now with alpha12 to replace my lambda with function reference (I marked the problem place with FIXME) and it compiles fine. I guess my problem is fixed now. Are you sure you are using latest compose compiler? Or maybe these are not same issues after all
r

robnik

02/12/2021, 10:09 PM
Did you try my code snippet? Without the
Scafford
part it compiles okay, so not not all function refs are a problem. Pretty sure I'm using alpha12.
a

Alex Bieliaiev

02/13/2021, 8:43 AM
@robnik did you try to move nested
foo
function to the top-level scope?
v

Vsevolod Ganin

02/13/2021, 11:06 AM
Did you try my code snippet?
Ok, tried now and can confirm that compiler crashes. Compiler definitely shouldn’t crash. From the stacktrace I got the idea that it has to do with Compose compiler so imo you should file a bug to compiler component https://issuetracker.google.com/issues?q=componentid:610764
r

robnik

02/13/2021, 3:46 PM
Looks like moving the nested function to top-level also fixes it. I reported a bug.
👍 2