title: Java8: Using Function::identity in Collectors.toMap(..) creates an argument mismatch error
body: <p>Given this simple Person POJO:</p>
  
  <pre><code>public class Person {
      private String id;
      private String name;
  
      public Person(String id, String name) {
          super();
          this.id = id;
          this.name = name;
      }
  
      public String getId() {
          return id;
      }
  
      public String getName() {
          return name;
      }
  }
  </code></pre>
  
  <p>I would like to collect a <code>Map&lt;String, Person&gt;</code> where the key is the <code>id</code> of the Person.</p>
  
  <p>I have tried to implement it like this:</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  import java.util.Map;
  import java.util.function.Function;
  import java.util.stream.Collectors;
  
  public class CollectorMain {
      public static void main(String[] args) {
          List&lt;Person&gt; list = new ArrayList&lt;&gt;();
          list.add(new Person("312", "John"));
          list.add(new Person("454", "Alice"));
          list.add(new Person("712", "Bob"));
  
          Map&lt;String, Person&gt; map = list.stream()
                 .collect(
                      Collectors.toMap(Person::getId, Function::identity) // COMPILE ERROR
                 );
          System.out.println(map.size());
      }
  }
  </code></pre>
  
  <p>But I get a compile error:</p>
  
  <pre><code>CollectorMain.java:[14,41] no suitable method found for toMap(Person::getId,Function::identity)
      method java.util.stream.Collectors.&lt;T,K,U&gt;toMap(java.util.function.Function&lt;? super T,? extends K&gt;,java.util.function.Function&lt;? super T,? extends U&gt;) is not applicable
        (cannot infer type-variable(s) T,K,U
          (argument mismatch; incompatible parameter types in method reference))
      method java.util.stream.Collectors.&lt;T,K,U&gt;toMap(java.util.function.Function&lt;? super T,? extends K&gt;,java.util.function.Function&lt;? super T,? extends U&gt;,java.util.function.BinaryOperator&lt;U&gt;) is not applicable
        (cannot infer type-variable(s) T,K,U
          (actual and formal argument lists differ in length))
      method java.util.stream.Collectors.&lt;T,K,U,M&gt;toMap(java.util.function.Function&lt;? super T,? extends K&gt;,java.util.function.Function&lt;? super T,? extends U&gt;,java.util.function.BinaryOperator&lt;U&gt;,java.util.function.Supplier&lt;M&gt;) is not applicable
        (cannot infer type-variable(s) T,K,U,M
          (actual and formal argument lists differ in length))
  </code></pre>
  
  <hr>
  
  <p>As a solution I can replace <code>Function::identity</code> with this lambda <code>p -&gt; p</code> like this:</p>
  
  <pre><code>Map&lt;String, Person&gt; map = list.stream()
      .collect(
          Collectors.toMap(Person::getId, p -&gt; p)
      );
  </code></pre>
  
  <p>Is there a possibility to use <code>Function::identity</code> ?</p>