Dominaezzz
01/14/2020, 2:26 PMfun <T> List<T>.idk(): List<T> = TODO()
fun <T> List<T>?.idk(): List<T>? = TODO()
fun lol() {
val real: List<String> = emptyList()
val empty: List<String>? = emptyList()
real.idk() // Resolves the first function.
empty.idk() // Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type List<String>?
}
(Sorry about the names, they take up too much time to come up with)
This only happens when the receiver is generic. The functions resolve as expected for String
.Milan Hruban
01/14/2020, 2:31 PMidk
functions both have same JVM signature, so the second one is ignored I think. If you remove the last line ( empty.idk()....
,) you should still get compilation error right?Marat Akhin
01/14/2020, 3:00 PMDominaezzz
01/14/2020, 3:02 PMDominaezzz
01/14/2020, 3:03 PMString
, it compiles fine.Milan Hruban
01/14/2020, 3:19 PMDominaezzz
01/14/2020, 3:23 PMMarat Akhin
01/14/2020, 3:25 PM-Xnew-inference
? Seems like a possible bug in type inference, maybe it's fixed in the new version.Dominaezzz
01/14/2020, 3:26 PMDominaezzz
01/14/2020, 3:27 PMDominaezzz
01/14/2020, 3:27 PMDominaezzz
01/14/2020, 4:03 PMkotlinOptions {
freeCompilerArgs = listOf("-Xnew-inference")
}
fixes it.Marat Akhin
01/14/2020, 4:05 PMDominaezzz
01/14/2020, 4:09 PMMarat Akhin
01/14/2020, 4:10 PMDominaezzz
01/14/2020, 4:10 PM