Eclipse's "extract to method" on Function results in compilation error
<p>Starting with a class <code>A</code> with 2 fields, <code>name</code> and <code>id</code>, a constructor and getters, I wrote this test, which runs green:</p>

<pre><code>@Test
public void test() {
    List&lt;A&gt; list = Arrays.asList(new A(null, "a"), new A(null, "b"));

    Collections.sort(list,
            Comparator
            .comparing(A::getName, Comparator.nullsLast(Comparator.naturalOrder()))
            .thenComparing(A::getId, Comparator.nullsLast(Comparator.reverseOrder())));

    assertThat(list.get(0).id, is("b"));
}
</code></pre>

<p>However, if I select Eclipse's quick fix "extract to method" on <code>A::getName</code>:</p>

<p><a href="https://i.stack.imgur.com/McuHY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/McuHY.png" alt="extract to method"></a></p>

<p>I suddenly get 2 compilation errors on the next line (<code>thenComparing(...)</code>):</p>

<pre><code>@Test
public void test() {
    List&lt;A&gt; list = Arrays.asList(new A(null, "a"), new A(null, "b"));

    Collections.sort(list,
            Comparator
            .comparing(extracted(), Comparator.nullsLast(Comparator.naturalOrder()))
            .thenComparing(A::getId, Comparator.nullsLast(Comparator.reverseOrder())));

    assertThat(list.get(0).id, is("b"));
}

private Function&lt;? super A, ? extends String&gt; extracted() {
    return A::getName;
}
</code></pre>

<p>Saying:</p>

<blockquote>
  <p>The type Test.A does not define getId(capture#1-of ? super Test.A) that is applicable here</p>
</blockquote>

<p>and</p>

<blockquote>
  <p>The method thenComparing(Function&lt;? super capture#1-of ? super Test.A,? extends U>, Comparator&lt;? super U>) in the type Comparator is not applicable for the arguments (A::getId, Comparator&lt;Comparable&lt;? super Comparable&lt;? super T>>>)</p>
</blockquote>

<p>Why does this result in an error? What am I doing wrong?</p>