Try and catch generates compilation error

 

  btn.setOnClickListener {
           try {
           val rpc = XMLRPCClient(“rpc.rsscloud.org:5337/RPC2”, “”, “”)
           val res = rpc.call(“ping”, “http://rivers.silverkeytech.com/blogs/android-rivers/rss.xml” )
           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 {
  setOnClickListener(OnClickListener(action))
}

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 http://youtrack.jetbrains.com/issue/KT-3343

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