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

Klaas Kabini

04/02/2020, 12:36 PM
Why do we still have to put extra parenthesis in front of composable keyword?
Copy code
typealias ComposableFunction = @Composable() () -> Unit
instead of just doing this. But the AS does not allow this
Copy code
typealias ComposableFunction = @Composable () -> Unit
a

Andrew Neal

04/02/2020, 1:41 PM
It has to do with a compiler limitation and Compose passing in implicit parameters into every
@Composable
.
l

Louis Pullen-Freilich [G]

04/02/2020, 2:04 PM
I think this will go away in Kotlin 1.4, for now you need to add a compiler flag, you can set this in your
allProjects
block in the root `build.gradle`:
Copy code
allprojects {
   ...     tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            freeCompilerArgs += '-XXLanguage:+NonParenthesizedAnnotationsOnFunctionalTypes'
        }
    }
}
👍 2
k

Klaas Kabini

04/02/2020, 2:05 PM
Thank you
r

romainguy

04/02/2020, 3:44 PM
Yes this will go away, but we’re still using a fairly old base Kotlin compiler. We’re working on a rebase that should fix a lot of things (inline classes, etc.)
l

Leland Richardson [G]

04/03/2020, 3:12 PM
to be clear, this has nothing to do with the compose compiler and is just an oddity with kotlin’s language grammar. This was fixed and will be the default in 1.4 but can also be turned on with a flag currently. actually, AGP automatically adds this flag with the
compose true
flag, so it should actually compile, but android studio maybe won’t like it. Hope that makes sense.
👍 1