title: Why do I have to wrap my Kotlin method references in closures?
body: <p>In kotlin, I'm trying to create a dispatch table:</p>
  
  <pre><code>class Foo {
      fun handleEvent(bytes:ByteArray) {
          // do something fun with the bytes
      }
  }
  
  class Bar {
      fun handleEvent(bytes:ByteArray) {
          // do something fun with the bytes
      }
  }
  
  foo = Foo()
  bar = Bar()
  
  val eventHandlers:HashMap&lt;RemoteEvent, (bytes:ByteArray)-&gt;Unit&gt; = hashMapOf(
      0x01 to foo.handleEvent,
      0x02 to bar.handleEvent)
  </code></pre>
  
  <p>Kotlin doesn't seem to like this, it complains in multiple ways, but the relevant one seems to be be <code>function invocation expected</code>.</p>
  
  <p>I can fix this by wrapping those in closures:</p>
  
  <pre><code>val eventHandlers:HashMap&lt;RemoteEvent, (bytes:ByteArray)-&gt;Unit&gt; = hashMapOf(
      0x01 to { bytes -&gt; foo.handleEvent(bytes) },
      0x02 to { bytes -&gt; bar.handleEvent(bytes) })
  </code></pre>
  
  <p>Is there no other way? Why do I have to the method signatures, which are correct, in closures which are the same? Are closures and methods not on the same footing in Kotlin?</p>