Anyone gotten `when guards` to work in Android Stu...
# android
d
Anyone gotten
when guards
to work in Android Studio w/o warnigns? I'm running kotlin
2.2.0
and using latest stable Android Studio, also tested latest Canary, but still get warning about it being an experimental feature:
Copy code
The feature "when guards" is experimental and should be enabled explicitly. This can be done by supplying the compiler argument '-Xwhen-guards', but note that no stability guarantees are provided.
Building from command line and android studio works fine, however android studio still gives off warning. I have K2 mode enabled in Android Studio.
n
kotlin { sourceSets.all { languageSettings { optIn("kotlin.experimental.ExperimentalWhenGuards") } } } tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach { kotlinOptions { freeCompilerArgs += "-Xwhen-guards" } }
you can try this code
d
I know I can add it by marking it as experimental, but the feature is stable and it should not be needed.
I don't want to add a flag just to please Android Studio 😅
n
then i don't know what was your problem about warning
🤕