How to specify return type for callback function and forget about it

Callback:

var onclose:(()->Unit)? = null

My function:

sockJs.onclose = {
  if (connecting) {
  reconnectTimeoutId = setTimeout({
                                          sockJs = SockJS(uri)
                                   }, 500)
  }
  else if (closed != null) {
  closed!!()
  }
  }

All is ok.

Add new else clause:

sockJs.onclose = {
  if (connecting) {
  reconnectTimeoutId = setTimeout({
                                          sockJs = SockJS(uri)
                                   }, 500)
  }
  else if (closed != null) {
  closed!!()
  }
  else {
  try {
          console.info(“dd”)
  }
  catch (e:Exception) {
          console.error(e)
  }
  }
  }

Error: /uploads/kotlinlang/original/1X/e550845cfbd09e753dc0818d35409bc0021afbcb.png

How I can specify “void” (like java or acrionscript) and forget about callback return type?

You can say

{ () : Unit -> …

}

at the beginning of the function literal.

But this seems like a bug in type-checking try. Could you report it to the tracker? Thanks