CLOVIS
02/22/2026, 7:47 PMkotlin {
sourceSets.configureEach {
languageSettings {
enableLanguageFeature("context-parameters")
}
}
}
and
kotlin {
compilerOptions {
freeCompilerArgs.add("-Xcontext-parameters")
}
}
Which is more idiomatic?
• Only the second one gets recognized up by IntelliJ
• However, enableLanguageFeature seems clearer than freeCompilerArgsJames Yox
02/22/2026, 9:55 PMlanguageSettings.enableLanguageFeature("ContextParameters")
For me at leastJames Yox
02/22/2026, 9:57 PMZac Sweers
02/22/2026, 10:15 PMJavier
02/22/2026, 10:27 PMkotlin {
sourceSets.configureEach {
languageSettings {
enableLanguageFeature(LanguageFeature.ContextParameters.name)
}
}
}Javier
02/22/2026, 10:28 PMenableLanguageFeature(LanguageFeature.ContextParameters)CLOVIS
02/23/2026, 8:04 AMsourceSets.configureEach {} approach compiles correctly from the CLI, but the IDE complains that context parameters are not enabled.tapchicoma
02/23/2026, 8:11 AMenableLanguageFeatures API is deprecated in Kotlin 2.3.20 release. This API uses Kotlin compiler internal flags which is not intended by used by users.
Also, in general, languageSettings API is soft-deprecated in favor of kotlin.compilerOptions DSL.Javier
02/23/2026, 12:20 PMkotlin.compilerOptions.languageFeatures(listOf(LanguageFeature.ContextParameters, ...))
// or only for experimental "public" features
kotlin.compilerOptions.experimentalFeatures(listOf(ExperimentalFeature.ContextParameters, ...))
Adding complexity to try new features is just make users angry. I do not ever know how many times I have looked at Google to add "-Xcontext-parameters" because I forgot if it was with -, or _, if it is -X, etc.tapchicoma
02/23/2026, 4:40 PM-X arguments in the DSL: KT-61035 Expose experimental compiler arguments in the Gradle DSL
The problem is that currently -X arguments are a mix of everything making it hard to design a proper DSL. For example, not everything in -X is experimental which could be removed/changed in any Kotlin release. We are working on this and hopefully this year we will address it.