title: type inference based on generic argument type (Delphi)
body: <p>I'm trying to write a generic function that accepts matching parameter types.<br>
  Delphi does infer the type parameter correctly in the simple case of plain arguments.</p>
  
  <p>eg:</p>
  
  <pre><code>type
    TFoo = class
      function Pair&lt;T&gt;(e1, e2: T): TList&lt;T&gt;;
    end;
  </code></pre>
  
  <p>calling this with <code>aFoo.Pair(1, 2);</code> works perfectly fine, but when I change the parameter signature to a generic type</p>
  
  <pre><code>type
    TFoo = class
      function InsertInto&lt;T&gt;(aList: TList&lt;T&gt;; aVal: T): TList&lt;T&gt;;
    end;
  </code></pre>
  
  <p>and try to call it<br>
  <code>aFoo.InsertInto(TList&lt;String&gt;.Create, 'bar');</code></p>
  
  <p>then the compiler complains about it:<br>
  <code>E2010 Incompatible types: 'Generics.Collections.TList&lt;uTest.TFoo.InsertInto.T&gt;' and 'Generics.Collections.TList&lt;System.String&gt;'</code></p>
  
  <p>Is there any way I can write this (or a similar) method, so that the client doesnt have to specity the type parameter?<br>
  <code>aFoo.InsertInto&lt;String&gt;(TList&lt;String&gt;.Create, 'bar');</code></p>