Why Kotlin DSL and Grovvy flags are different? doesn’t looks as right snippet, probably only one is correct: Groovy DSL flag is correct, so Kotlin DSL should be:
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-XXLanguage:+NewInference"
}
}
I also add compiler flags instead of replacing existing ones and use Kotlin DSL API with reified generics to make snippet more Kotlin DSL friendly