lakakhara
10/31/2025, 3:36 PMIterable<T>.sumOf(selector: (T) -> Dp): Dp but for some reason compiler want to use it even for other types like Int and Double. I added annotation OverloadResolutionByLambdaReturnType that if I got it right should alter preference, but it doesn't.
@OptIn(ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@JvmName("sumOfDp")
inline fun <T> Iterable<T>.sumOf(selector: (T) -> Dp): Dp {
var sum: Dp = 0.dp
for (element in this) {
sum += selector(element)
}
return sum
}
I know that I can just sum Dp.value.toDouble() but I want to know where the problem isephemient
10/31/2025, 3:41 PMimport kotlin.collections.sumOf
so that both the default sumOf and your sumOf are considered