Youssef Shoaib [MOD]
12/23/2025, 12:07 PMfun List<*>.foo() {}
emptyList().foo()
I get an error on emptyList(). I understand why, of course, but it feels like overprecise initialisation to me!
This example would be nice to support as well, although I can imagine it'd be harder:
fun List<String>.foo() {}
emptyList().foo()
(thus `emptyList`'s type arg is String)dmitriy.novozhilov
12/23/2025, 12:09 PMfun List<*>.foo() {}
fun List<String>.foo() {}
emptyList().foo()Youssef Shoaib [MOD]
12/23/2025, 12:16 PMString overload:
fun List<*>.foo() { println(1) }
fun List<String>.foo() { println(2) }
buildList { foo() } // prints 2
but it does report ambiguity in this case:
fun List<Int>.foo() { println(1) }
fun List<String>.foo() { println(2) }
buildList { foo() }
Roughly, I want these "overprecise initialisation" situations to behave like builder inference. It sounds like maybe outference could do thisYoussef Shoaib [MOD]
12/23/2025, 12:28 PMfun <K> Map<K, *>.foo(key: K) {}
emptyMap().foo("foo")