Try and catch generates compilation error


  btn.setOnClickListener {
           try {
           val rpc = XMLRPCClient(“”, “”, “”)
           val res =“ping”, “” )
           Log.d(TAG, “Return content $res”)
           catch(e : Exception){
           Log.d(TAG, “Call RPC error ${e.getMessage()}”)

If I remove try-catch statement everything just works.

This is the error

Kotlin: Type mismatch: inferred type is jet.Int but Unit was expected

This is the declaration of the extension method


public fun View.setOnClickListener(action: (View?) -> Unit): Unit {

Does LOG.d() return an Int?

In any case, this looks like a bug. Please report a short repro example to the tracker. Thanks

Yup, Log.d returns Int.

The case is here

The workaround would be to put Unit.VALUE on the last line before catch