I've broken Kotlin compiler backend

This code caused Kotlin compiler backend to fail. I’m using Kotlin 1.3.61 with Jetpack Compose 0.1.0-dev03. The affected function:

    @Composable
    private fun RandomActivityButton() {
        lateinit var onClickNormal: () -> Unit
        lateinit var onClick: State<() -> Unit>

        onClickNormal = {
            val intent = Intent(
                this@MainActivity,
                ActivityDescriptionActivity::class.java
            )

            val activity = mainScope.async(Dispatchers.IO) {
                //BoredApi().randomAsync().await()
                BoredApi().byCriterionsAsync { Key set 6509779 }.await()
            }

            onClick.value = {}

            mainScope.launch {
                intent.putExtra("activity", activity.await())
                startActivity(intent)
                onClick.value = onClickNormal
            }
        }

        onClick = +state { onClickNormal }

        Button(
            text = "navigate",
            onClick = onClick.value
        )
    }

./gradlew build output: 123 · GitHub

I can provide the complete project and environment information if it will help.

My current workaround is replacing lambda with an anonymous function:

    @Composable
    private fun RandomActivityButton() {
        lateinit var onClickNormal: () -> Unit
        lateinit var onClick: State<() -> Unit>

        onClickNormal = {
            val intent = Intent(
                this@MainActivity,
                ActivityDescriptionActivity::class.java
            )

            val activity = mainScope.async(Dispatchers.IO) {
                //BoredApi().randomAsync().await()
                BoredApi().byCriterionsAsync(fun BoredApi.CriterionSelection.() {
                    Key set 6509779
                }).await()
            }

            onClick.value = {}

            mainScope.launch {
                intent.putExtra("activity", activity.await())
                startActivity(intent)
                onClick.value = onClickNormal
            }
        }

        onClick = +state { onClickNormal }

        Button(
            text = "navigate",
            onClick = onClick.value
        )
    }

This is a bug in the new experimental IR JVM backend. Please file an issue at http://kotl.in/issue with a sample project to reproduce. Thanks!

I broke YouTrack by uploading affected project’s snapshotimage

Thanks for noticing, we’ll investigate.

For reference, the issue is https://youtrack.jetbrains.com/issue/KT-36272.