title: How to define class with self-referencing generics constraint in Delphi?
body: <p>As shown in this <a href="http://dvanderboom.wordpress.com/2008/03/15/treet-implementing-a-non-binary-tree-in-c/" rel="nofollow noreferrer">article</a>, one can define in C#:</p>
  
  <pre><code>public class MyTreeNode&lt;T&gt; where T: MyTreeNode&lt;T&gt;
  {
  
  }
  </code></pre>
  
  <p>In Delphi, however, the following code does not compile and complains "E2003 Undeclared identifier: 'MyTreeNode&lt;>'":</p>
  
  <pre><code>type
      TMyTreeNode&lt;T: TMyTreeNode&lt;T&gt;&gt; = class
      end;
  </code></pre>
  
  <p>The formal terminology seems to be <a href="http://rtb.rousso.eu/2013/06/self-referencing-generic-type-constraint.html" rel="nofollow noreferrer">"self-referencing generics constraint"</a>. I wonder how to do this in Delphi ?</p>
  
  <p>PS: </p>
  
  <p><a href="http://blogs.msdn.com/b/ericlippert/archive/2011/02/03/curiouser-and-curiouser.aspx" rel="nofollow noreferrer">Another useful article as David pointed out</a>. </p>
  
  <p><a href="https://stackoverflow.com/questions/22404734/">Relevent SO post regarding Delphi and covariance / contravariance</a>. </p>
  
  <p><a href="http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29" rel="nofollow noreferrer">Wikipedia page of co/contra-variance</a>.</p>