Why can't this be inferred from usage? I have two...
# getting-started
m
Why can't this be inferred from usage? I have two extension functions:
Copy code
inline fun <T> Collection<T>.associateByPeriod(keySelector: (T) -> Period<LocalDate>): LocalDatePeriodMap<T?> = ...
inline fun <T> Collection<T>.associateByPeriod(keySelector: (T) -> Period<LocalDateTime>): LocalDateTimePeriodMap<T?> = ...
now somewhere in my code I am doing
Copy code
list.associateByPeriod{ it.period } //period being a Period<LocalDateTime>
now I still get the exception
Copy code
Overload resolution ambiguity. All these functions match.
but the first one can't match because of typing. am I forced to make different function names for each periodMap?
y
You need to annotate one of the functions at least with
@OverloadResolutionByLambdaReturnType
K 4
😯 2
👋 1