title: Java 8 method reference type inference
body: <p>I'm confused by a bit of Java 8's type inference.  The following code:</p>
  
  <pre><code>private static &lt;T&gt; Function&lt;Iterable&lt;? extends T&gt;, Iterator&lt;? extends T&gt;&gt;
      toIterator() {
    return Iterable&lt;? extends T&gt;::iterator;
  }
  </code></pre>
  
  <p>breaks with the compile error</p>
  
  <pre><code>error: incompatible types: invalid method reference
      return Iterable&lt;? extends T&gt;::iterator;
             ^
      method iterator in interface Iterable&lt;T#2&gt; cannot be applied to given types
        required: no arguments
        found: Iterable&lt;? extends T#1&gt;
        reason: actual and formal argument lists differ in length
    where T#1,T#2 are type-variables:
      T#1 extends Object declared in method &lt;T#1&gt;toIterator()
      T#2 extends Object declared in interface Iterable
  </code></pre>
  
  <p>whereas removing the explicit generic</p>
  
  <pre><code>private static &lt;T&gt; Function&lt;Iterable&lt;? extends T&gt;, Iterator&lt;? extends T&gt;&gt;
      toIterator() {
    return Iterable::iterator;
  }
  </code></pre>
  
  <p>works, as does the old-school anonymous inner class</p>
  
  <pre><code>private static &lt;T&gt; Function&lt;Iterable&lt;? extends T&gt;, Iterator&lt;? extends T&gt;&gt;
      toIterator() {
    return new Function&lt;Iterable&lt;? extends T&gt;, Iterator&lt;? extends T&gt;&gt;() {
      @Override
      public Iterator&lt;? extends T&gt; apply(Iterable&lt;? extends T&gt; iterable) {
        return iterable.iterator();
      }
    };
  }
  </code></pre>
  
  <p>Can anyone suggest what might be going on here?</p>