title: Java generics & incompatible types: bug in compiler?
body: <p>I've got "incompatible types" compiler error in condition not yet discussed in stackoverflow (e.g. <a href="https://stackoverflow.com/questions/662191/why-wont-this-generic-java-code-compile%20#1">Why won't this generic java code compile?</a>). </p>
  
  <p>My expectation is simple - I'm calling a templated method which does not use any 'generic' classes from containing class, therefore it should extract types of template parameters from method arguments and this should compile in all cases - but I get "incompatible types" compiler error.</p>
  
  <p>I've noticed strange way to fix the problem - adding "<em>&lt; ? extends Data ></em>" to generic datatype in method arguments. How does it change compiler logic? </p>
  
  <p>In my understanding - there should be no difference because (1) DataContainer class' template parameters are not used in method call and (2) restriction "<em>&lt; TData extends Data ></em>" already defines minimal base object class - Data - and therefore it should be automatically assumed when compiling template without arguments.</p>
  
  <pre><code>public void processData(DataContainer&lt;? extends Data&gt; c) {
  </code></pre>
  
  <p>(explicit type casting can be used, but i believe it is redundant here)</p>
  
  <pre><code>DummyContextClass dcc = (DummyContextClass)c.getContext(DummyContextClass.class);
  </code></pre>
  
  <p>Code for copy/paste</p>
  
  <pre><code>public class Test {
  
      public static class Data {
      }
  
      public static class DataContainer&lt;TData extends Data&gt; {
          public final TData Data;
          private final Map&lt;String, Object&gt; contexts = new HashMap&lt;&gt;();
  
          public DataContainer(TData data) {
              Data = data;
          }
  
          public &lt;T&gt; T getContext(Class&lt;T&gt; type) {
              return (T)contexts.get(type.getName());
          }
  
          public &lt;T&gt; void setContext(Class&lt;T&gt; type, T context) {
              contexts.put(type.getName(), context);
          }
      }
  
      public static class DummyContextClass {
      }
  
      public void processData(DataContainer c) {
          c.setContext(DummyContextClass.class, new DummyContextClass());
  
          // error: incompatible types: Object cannot be converted to DummyContextClass
          DummyContextClass dcc = c.getContext(DummyContextClass.class);
      }
  }
  </code></pre>