Function reference instead of anonymous lambda not working?

Hi,

I have a strange problem which I try to understand. I’ve defined

    private val canvas: HTMLCanvasElement
    ...
    fun register(handler: (Event) -> Unit) {
        canvas.addEventListener("keydown", handler)
    }

When I call register with a lambda function, key events are correctly handled, i.e. this works as expected:

    register { e -> window.alert(e.toString()) }

but when I use a function reference, nothing happens:

   register(::function)
   ...
   fun function(e: Event) { window.alert(e.toString()) }

despite both parameters of register having the same signature.

What am I missing?

Best,
Michael

It might be a bug in the compiler and/or webpack actually. I had the same problem before and when I added a println that accessed and printed some data, the function started to work.

I planned to make a bug report of this but haven’t had the time to make a small example to present the bug yet.

Interestingly this was not a problem during this spring, it was announced sometime during summer or very end of spring.

    override fun onConfigure() {
        onExecuteResult = ::onExecuteResult
    }

    private fun onExecuteResult(resultBo: BaseBo) {
        // TODO remove this when fixed in compiler, when not here onExecuteResult is not executed
        if (resultBo is ActionStatus && resultBo.success) println("login successful")
        onSuccess()
    }