title: Lambda expression doesn't working in seemingly identical kotlin
body: <p>When trying to create a simple database helper, I have a <code>RowMapper&lt;T&gt;</code> from Spring that I want to fill in, but Kotlin insists on using <code>KFunction2</code>, even though the interface of <code>RowMapper</code> matches. This works on the raw interface from the Spring Java code.</p>
  
  <p>To me it looks like the methods have identical at the important parts. However, Kotlin does not agree with me.</p>
  
  <p>My interface (kotlin) looks as follows:</p>
  
  <pre><code>interface MyJdbcOperations : NamedParameterJdbcOperations {
      fun &lt;T&gt; querySingle(
          sql: String,
          parameters: MapSqlParameterSource,
          rowMapper: RowMapper&lt;T&gt;): Optional&lt;T&gt;
  }
  </code></pre>
  
  <p>The interface of query inside <code>NamedParameterJdbcOperations</code> looks as follows (Java):</p>
  
  <pre class="lang-java prettyprint-override"><code>public interface NamedParameterJdbcOperations {
      // ... rest of interface omitted for readability
  
      &lt;T&gt; List&lt;T&gt; query(String sql, SqlParameterSource paramSource, RowMapper&lt;T&gt; rowMapper)
              throws DataAccessException;
  }
  </code></pre>
  
  <p>But when I use my implementation of <code>MyJdbcOperations</code> as follows:</p>
  
  <pre><code>template.query&lt;Foo&gt;(sql, parameters, this::mapToFoo)
  template.querySingle&lt;Foo&gt;(sql, parameters, this::mapToFoo)
  </code></pre>
  
  <p>The first version works, no problem, and I can also remove <code>&lt;Foo&gt;</code> and let type inference do its job.</p>
  
  <p>The second version however gives me errors like:</p>
  
  <pre><code>Error:(25, 54) Kotlin: Type mismatch: inferred type is KFunction2&lt;@ParameterName ResultSet, @ParameterName Int, Foo&gt; but RowMapper&lt;Foo&gt; was expected
  </code></pre>
  
  <p>However I actually expected this to just work, if the <code>KFunction2</code> signature can satisfy <code>RowMapper&lt;Foo&gt;</code> in the Java interface, then I most certainly would expect it to be able to in Kotlin too. This is obviously not the case.</p>
  
  <p>So what am I doing wrong, and what is the best way to fix it?</p>