title: Yet another Java generics "incompatible types" compilation error
body: <p>I was writing some code and came across a <code>incompatible types</code> compilation error.
  This is what I have:</p>
  
  <pre><code>public interface Expression&lt;T&gt; {
      int getArity();
      T evaluate();
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public abstract class Value&lt;T&gt; implements Expression&lt;T&gt; {
      @Override
      public final int getArity() { return 0; }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public final class Constant&lt;T&gt; extends Value&lt;T&gt; {
      private final T value;
  
      /** Parameter constructor of objects of class Constant. */
      public Constant(T val) {
          value = val;
      }
  
      /** Copy constructor of objects of class Constant. */
      private Constant(Constant instance) {
          value = instance.evaluate();    // Error here.
      }
  
      @Override
      public T evaluate() { return value; }
  }
  </code></pre>
  
  <p>I thought I wasn't declaring generics correctly when using inheritance, so I checked <a href="http://docs.oracle.com/javase/tutorial/java/generics/inheritance.html" rel="nofollow">Oracle's tutorial</a>, in which they write</p>
  
  <pre><code>interface PayloadList&lt;E,P&gt; extends List&lt;E&gt;
  </code></pre>
  
  <p>The above declaration uses the same generic type <code>E</code>, which is what I want to accomplish in my example. It seems to be assuming that the <code>T</code> from <code>Constant&lt;T&gt;</code> is different from the one from <code>Value&lt;T&gt;</code>. Otherwise it should be able to <em>merge</em> both <code>T</code> and see it's the same type.
  How can I correctly implement what I'm trying to achieve?</p>
  
  <p>(<em>Ie, a constant of something is a value of something, which is an expression of the same something</em>)</p>