Is there any particular reason that ``` class Reac...
# announcements
s
Is there any particular reason that
Copy code
class ReactMap : MutableMap<Long, MutableList<EmoteData>> by (mutableMapOf<Long, MutableList<EmoteData>>()
    .withDefault { mutableListOf<EmoteData>() })
compiles fine, and
Copy code
class ReactMap : MutableMap<Long, MutableList<EmoteData>> by mutableMapOf()
compiles fine, but
Copy code
class ReactMap : MutableMap<Long, MutableList<EmoteData>> by (mutableMapOf().withDefault { mutableListOf() })
doesn't? Is it a bug in the compiler, or is it intentional?
😕 1
d
It's because the
mutableMapOf()
invocation can't infer type arguments in the last example. It might work if you enable the improved type inference, but I'm not sure.
s
How do I enable that?
d
I'm not sure, look for the blog post on 1.3 I guess
It should be a compiler argument
Copy code
tasks.withType<KotlinCompile> {
        kotlinOptions {
            jvmTarget = "1.8"
            freeCompilerArgs = listOf(
                "-XXLanguage:+InlineClasses",
                "-XXLanguage:+NewTypeInference",
                "-Xuse-experimental=kotlin.Experimental"
            )
        }
    }
^ Using kotlin gradle DSL
-XXLanguage:+NewTypeInference
👌 1