How to deal with an overload resolution ambiguity of functions with generics?
问题 Consider this class with two functions, one with Int argument, the other with a generic one: class C<K, V> { // ... operator fun f(index: Int): Pair<K, V> = ... operator fun f(key: K): V = ... } When it is parameterized as C<Int, SomeType> , K is Int , and both functions match the calls, resulting into an error: val m = C<Int, SomeType>() m.f(1) Overload resolution ambiguity. All these functions match: public final fun f(index: Int): SomeType defined in C public final fun f(key: Int): Pair