andylamax
06/19/2022, 10:48 PMclass Zipped<out T>(val value:T)
// function one
fun <T,R> Zipped<T>.map(mapper: (T)->R): Zipped<R> {
// . . .
}
// function two
fun <T,R> Zipped<Zipped<T>>.map(mapper: (T)->R) : Zipped<R> {
// . . .
}
fun main() {
val zipped: Zipped<Zipped<Int>> = Zipped(Zipped(2))
val result = zipped.map { "zipped value: $it" } // when calling this function?
}
Vampire
06/20/2022, 12:53 AMVampire
06/20/2022, 12:57 AMZipped<T>
.ephemient
06/20/2022, 1:55 AM@JvmName
to rename themephemient
06/20/2022, 1:57 AM@JvmName("zippedMap") fun <T, R> Zipped<T>.map(mapper: (T) -> R): Zipped<R> = ...
@JvmName("zipped2Map") fun <T, R> Zipped<Zipped<T>>.map(mapper: (T) -> R): Zipped<R> = ...
andylamax
06/20/2022, 1:58 AMandylamax
06/20/2022, 1:58 AMephemient
06/20/2022, 1:59 AMandylamax
06/20/2022, 2:07 AMZipped(0).map {
it + 1
}.map {
Zipped(it)
}.map { // override resolution ambiguity happens here
it + 1
}
Youssef Shoaib [MOD]
06/20/2022, 6:09 AMephemient
06/20/2022, 10:56 AM.map { it: Int -> it + 1 }
would make override resolution unambiguousGleb Minaev
06/20/2022, 12:56 PMkotlin.internal.LowPriorityInOverloadResolution
should solve the problem.
Currently, (if I am not mistaken) it is considered to make the declaration public (KT-32618). Also I had a bit similar issue (KT-51899) with such ambiguity.