How to resolve overload ambiguity in method references?

Say I want to assign the java method Log.d(String, String) to a variable x of method type (String, String) -> Int and I do it like this:

val x: (String, String) -> Int = android.util.Log::d

The compiler says:

Error:(50, 56) Overload resolution ambiguity:
public open fun d(tag: kotlin.String!, msg: kotlin.String!): kotlin.Int defined in android.util.Log
public open fun d(tag: kotlin.String!, msg: kotlin.String!, tr: kotlin.Throwable!): kotlin.Int defined in android.util.Log

Obviously there is a second method Log.d(String, String, Throwable) but how do I tell the compiler which one I want?


  • Disambiguation here is currently unsupported (will be supported later).

    As a workaround, you can use a lambda expression:

    { s, s1 -> android.util.Log.d(s, s1) }