title: Method reference and Generics in Java-8
body: <p>I am facing issue with <em>method reference</em> combined with generic types.</p>
  
  <p>We have code where we need to call a overloaded method, but it is failing with error:</p>
  
  <blockquote>
    <p>Cannot resolve value m1()</p>
  </blockquote>
  
  <p>I have simplified my problem to make it clear where the problem lies. </p>
  
  <p>The following code fails:   </p>
  
  <pre><code>public class Test {
      void test() {
          // Getting error here
          setValue(C1::m1, Integer.ONE);
      }
  
      &lt;E extends I1, T&gt; void setValue(BiConsumer&lt;E, T&gt; cons, T value) {
      }
  }
  
  interface I1 {
  }
  
  class C1 implements I1 {
      void m1(Integer value) {
      }
  
      void m1(int value) {
      }
  }
  </code></pre>
  
  <p>Can someone please why this is behaving like this ?</p>
  
  <p>Kindly note this is not related to the question <a href="https://stackoverflow.com/questions/22717234/java-8-method-reference-with-generic-types">Java 8 Method reference with generic types</a></p>