# New Type Inference in Kotlin 1.3.0-rc-190

**URL:** <https://discuss.kotlinlang.org/t/new-type-inference-in-kotlin-1-3-0-rc-190/9914>\
**Category:** Support\
**Created:** [October 19, 2018, 9:39am UTC](https://discuss.kotlinlang.org/t/new-type-inference-in-kotlin-1-3-0-rc-190/9914 "2018-10-19T09:39:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andriy.hulyk](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@andriy.hulyk](https://discuss.kotlinlang.org/u/andriy.hulyk)\
**Post date:** [October 19, 2018, 9:39am UTC](https://discuss.kotlinlang.org/t/new-type-inference-in-kotlin-1-3-0-rc-190/9914/1 "2018-10-19T09:39:49Z")

</div>

Hi,  
according to that video [KotlinConf 2018 - New Type Inference and Related Language Features by Svetlana Isakova - YouTube](https://www.youtube.com/watch?v=MyljSWm0Y_k) i would like to try New Type Inference.

But i can not activate it ☹  
Preconditions:

Android Studio 3.3 Canary 13  
Build #AI-182.4505.22.33.5035453, built on September 28, 2018  
JRE: 1.8.0\_152-release-1248-b01 x86\_64  
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o  
macOS 10.14  
Gradle 4.10.2 with Kotlin DSL  
Kotlin “gradle-plugin” version 1.3.0-rc-190  
Kotlin “stdlib-jdk7” version 1.3.0-rc-190

The only available experimental option is “coroutines”.  
Please advice! Thank you in advance!

---

<div class="post-metadata">

**Author:** ![andriy.hulyk](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@andriy.hulyk](https://discuss.kotlinlang.org/u/andriy.hulyk)\
**Post date:** [October 19, 2018, 2:32pm UTC](https://discuss.kotlinlang.org/t/new-type-inference-in-kotlin-1-3-0-rc-190/9914/2 "2018-10-19T14:32:54Z")

</div>

adding following options to the gradle script will fix the issue:

```auto
afterEvaluate {
    tasks.withType(KotlinCompile::class)
        .forEach {
            it.kotlinOptions { freeCompilerArgs = listOf("-Xnew-inference") }
        }
}
```

---

<div class="post-metadata">

**Author:** ![Alexey.Belkov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/alexey.belkov/32/5215_2.png) [@Alexey.Belkov](https://discuss.kotlinlang.org/u/Alexey.Belkov)\
**Post date:** [October 19, 2018, 2:33pm UTC](https://discuss.kotlinlang.org/t/new-type-inference-in-kotlin-1-3-0-rc-190/9914/3 "2018-10-19T14:33:33Z")

</div>

This has been answered in Slack [Slack](https://kotlinlang.slack.com/archives/C0922A726/p1539935977000100) but I’ll repeat the answer for others here:

> This flag hasn’t landed in the compiler yet. You have to use the old `-X` flags for now.

Groovy DSL:

```auto
compileKotlin {
    kotlinOptions {
        freeCompilerArgs = ["-XXLanguage:+NewInference"]
    }
}

```

Kotlin DSL:

```auto
tasks.withType(KotlinCompile::class)
        .forEach {
            it.kotlinOptions { freeCompilerArgs = listOf("-Xnew-inference") }
        }

```

---

<div class="post-metadata">

**Author:** ![gildor](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/gildor/32/1891_2.png) [@gildor](https://discuss.kotlinlang.org/u/gildor)\
**Post date:** [November 7, 2018, 6:47am UTC](https://discuss.kotlinlang.org/t/new-type-inference-in-kotlin-1-3-0-rc-190/9914/4 "2018-11-07T06:47:24Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![LouisCAD](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/louiscad/32/4523_2.png) [@LouisCAD](https://discuss.kotlinlang.org/u/LouisCAD)\
**Post date:** [March 20, 2019, 3:55pm UTC](https://discuss.kotlinlang.org/t/new-type-inference-in-kotlin-1-3-0-rc-190/9914/5 "2019-03-20T15:55:30Z")

</div>

What’s the proper way to enable it with Kotlin multiplatform plugin and `languageSettings` in the Gradle DSL?

Note that I’m using Gradle Kotlin DSL, but I don’t think it’s different when used with Groovy for the new MPP plugin.

---

<div class="post-metadata">

**Author:** ![LouisCAD](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/louiscad/32/4523_2.png) [@LouisCAD](https://discuss.kotlinlang.org/u/LouisCAD)\
**Post date:** [July 7, 2019, 12:54pm UTC](https://discuss.kotlinlang.org/t/new-type-inference-in-kotlin-1-3-0-rc-190/9914/6 "2019-07-07T12:54:03Z")

</div>

Answering my own question:

```
enableLanguageFeature("NewInference")

```

In a `build.gradle.kts` file, it looks like this:

```auto
kotlin {
    ...
    sourceSets {
        all {
            languageSettings.apply {
                enableLanguageFeature("NewInference")
            }
        }
        ...
    }
    ...
}

```
