Is there a way to enable `kotlin.result` in common...
# announcements
a
Is there a way to enable
kotlin.result
in commonMain source set? I tried all the solutions below(in the thread), and it still shows me the error. However it worked on the other targets.
Copy code
metadata {
            compilations.all {
                kotlinOptions {
                    freeCompilerArgs = listOf("-Xallow-result-return-type", "-Xopt-in=kotlin.RequiresOptIn")
                }
            }
        }
Copy code
all {
            languageSettings.apply {
                useExperimentalAnnotation("kotlin.Experimental")
                useExperimentalAnnotation("-Xallow-result-return-type")
                enableLanguageFeature("AllowResultInReturnType")
                enableLanguageFeature(LanguageFeature.AllowResultInReturnType.toString())
            }
        }
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompile> {
            kotlinOptions {
                freeCompilerArgs = listOf("-Xallow-result-return-type")
            }
        }
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
            kotlinOptions {
                freeCompilerArgs = listOf("-Xallow-result-return-type")
            }
        }
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
            kotlinOptions {
                useIR = true
                jvmTarget = "11"
                freeCompilerArgs = listOf("-Xallow-result-return-type")
            }
        }
Copy code
targets.all {
            compilations.all {
                kotlinOptions {
                    freeCompilerArgs = freeCompilerArgs + "-Xallow-result-return-type"
                }
            }
        }
Nvm. The IDE shows an error but the code compiles.