Why do we still have to put extra parenthesis in f...
# compose
k
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
It has to do with a compiler limitation and Compose passing in implicit parameters into every
@Composable
.
l
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
Thank you
r
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
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