title: How is type inferred where return type is also upper and lower bound for method parameters
body: <p>Lets suppose we have the following code:</p>
  
  <pre><code>class A {}
  
  class B extends A {}
  
  class C extends B {}
  
  public static &lt;T&gt; T testMe(List&lt;? super T&gt; list1,List&lt;? extends T&gt; list2) {
      return null;
  }
  
  public static void main(String[] args) {
      List&lt;B&gt; listB = new ArrayList&lt;&gt;();
      List&lt;C&gt; listC = new ArrayList&lt;&gt;();
      // All three variants are possible:
      A a=testMe(listB, listC);
      B b=testMe(listB, listC);
      C c=testMe(listB, listC);
  }
  </code></pre>
  
  <p>The question is about <code>public static &lt;T&gt; T testMe(List&lt;? super T&gt; list1,List&lt;? extends T&gt; list2)</code>. How does the compiler determine the <code>T</code> type if if have three classes:<code>A,B,C,</code>? This question arose when I analysed <code>Collections.copy</code>.</p>