title: Overriding a generic method by a generic one in Java
body: <p>Angelica Langer says in her FAQ about generics (see <a href="http://www.angelikalanger.com/GenericsFAQ/FAQSections/TechnicalDetails.html#FAQ822">Technicalities.FAQ822</a>):</p>
  
  <blockquote>
    <p>If the methods have type parameters with different bounds , then they
    do not override, because the methods have signatures that are not
    override-equivalent.  Remember, the type parameter bounds are part of
    a generic method's signature.</p>
    
    <p>Example (of generic subtype methods overloading generic supertype
    methods; not recommended):</p>
    
    <pre class="lang-java prettyprint-override"><code>class Super {
     public &lt;T&gt; void set( T arg) { ... }
     public &lt;T&gt; T get() { ... }
  }
  class Sub extends Super {
     public &lt;S extends Number &gt; void set( S arg) { ... } // overloads
     public &lt;S extends Number &gt; S get() { ... }         // overloads
  }
  </code></pre>
  </blockquote>
  
  <p>I don't understand why the <code>get</code> method is overloaded in class <code>Sub</code>. For what I know it should be a compile time error because <code>get</code> has the same signature in both <code>Sub</code> and <code>Super</code> (the return type is not part of it).</p>
  
  <p>What confuse me even more is that the IDE I'm using to test the code (IntelliJ IDEA 14.0.3) highlights <code>get</code> in <code>Sub</code> as a compilation error with the next message:</p>
  
  <blockquote>
    <p>'get()' in 'Sub' clashes with 'get()' in 'Super'; both methods have the same erasure, yet neither overrides the other.</p>
  </blockquote>
  
  <p>But when I run the program it compiles and executes without problems. I suppose there is some kind of bug in IntelliJ when it analyzes the code, and what is correct is what Angelica tells in her FAQ. But I can't catch the point.</p>