I'm trying to perform the following line in Kotlin:
var str: KFunction<String> = String::toUpperCase
But compiler says:
Overload resolution ambiguity. All these functions match. public inline fun String.toUpperCase(): String defined in kotlin.text public inline fun String.toUpperCase(locale: Locale): String defined in kotlin.text
I thought that writing KFunction should overcome the ambiguity since not writing nothing before the String in KFunction means that the KFunciton shouldn't get parameters and only return a String (which compatible with the function that is defined in kotlin.text package, but it seems that the compiler want some more info. I'm also trying the following assignment:
var str: KFunction<java.util.Locale,String> = "some Word"::toUpperCase
And getting additional error saying that:
One type argument expected for interface KFunction
If I will use a method that isn't overloaded (like *toString) , So everything works. For Example:
var str: KFunction<String> = String::toString
What Am I missing here?