title: Java Generic type inference derived from method return type
body: <pre><code>public class TestCase {
      public static String compiles() {
          return getAction();
      }
  
      /*
      public static String doesntCompile1() {
          return (String) getAction();
      }
  
      public static String doesntCompile2() {
          return TestCase.&lt;String&gt; getAction();
      }
      */
  
      public static &lt;T extends javax.swing.Action&gt; T getAction() {
          return (T) null;
      }
  }
  </code></pre>
  
  <p>Should this be considered a bug in javac v1.6.0_22 and jdt v3.7.1?  To me it seems that way since in the other cases, the compiler actually finds the potential ClassCastException.  In the compiles method, this will throw at ClassCastException at runtime.</p>
  
  <p>The original code that brought this exemple didn't compile in javac, printing the following exception.  Unfortunately, the exemple code I provided for some reason will not generate this error.</p>
  
  <pre><code>type parameters of &lt;T&gt;T cannot be determined;
  no unique maximal instance exists for type variable T with upper bounds
  </code></pre>