title: Passing a listener object as a function parameter in kotlin
body: <p>I'm trying to pass a listener from an action to a class (an adapter).</p>
  
  <p>In java (code from the Action): </p>
  
  <pre><code>  private void setListeners() {
      adapterRecyclerView.setListener(
              new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      SomeCodehere....
                  }
              });
  }
  </code></pre>
  
  <p>(code from the adapter)</p>
  
  <pre><code>public void setListener(View.OnClickListener listener) {
      this.listener = listener;
  }
  </code></pre>
  
  <p>It works.</p>
  
  <p>Now I'm trying to traslate to kotlin. I translate first the action (translation the action to kotlin):</p>
  
  <pre><code>    private fun setListeners() {
      // !! is not fine i know
      adapterRecyclerView!!.setListener  { v  -&gt;
                            SomeCodehere....
      }
  }
  </code></pre>
  
  <p>At this point still works. With the code of the adapter still in java and code of the class in kotlin. Now I translate the adapter to kotlin:</p>
  
  <pre><code>fun setListener(listener: View.OnClickListener) {
      this.listener = listener 
  }
  </code></pre>
  
  <p>Now it doesn't work. The Action does not compile.</p>
  
  <p>Error:
  cannot infer a type for this parameter "v". 
  required View.OnClickListener. 
  found (???) Unit. </p>
  
  <p>How I must do the cast here?
  Why passing the parameter from kotlin to java works and from kotlin to kotlin it does not?</p>