Why is IEnumerable(of T) not accepted as extension method receiver : <p>Complete <strong>question</strong> before code:</p>

<p>Why is <code>IEnumerable&lt;T&gt;</code> <code>where T : ITest</code> not accepted as receiver of an extension method that expects <code>this IEnumerable&lt;ITest&gt;</code>?</p>

<p>And now the <strong>code</strong>:</p>

<p>I have three types:</p>

<pre><code>public interface ITest { }
public class Element : ITest { }
public class ElementInfo : ITest { }
</code></pre>

<p>And two extension methods:</p>

<pre><code>public static class Extensions
{
    public static IEnumerable&lt;ElementInfo&gt; Method&lt;T&gt;(
        this IEnumerable&lt;T&gt; collection) 
        where T : ITest
    {
→        return collection.ToInfoObjects();
    }

    public static IEnumerable&lt;ElementInfo&gt; ToInfoObjects(
        this IEnumerable&lt;ITest&gt; collection)
    {
        return collection.Select(item =&gt; new ElementInfo());
    }
}
</code></pre>

<p>The compiler error I get (on the marked line):</p>

<blockquote>
  <p><code>CS1929</code> : <code>'IEnumerable&lt;T&gt;'</code> does not contain a definition for <code>'ToInfoObjects'</code> and the best extension method overload <code>'Extensions.ToInfoObjects(IEnumerable&lt;ITest&gt;)'</code> requires a receiver of type <code>'IEnumerable&lt;ITest&gt;'</code></p>
</blockquote>

<p>Why is this so? The receiver of the <code>ToInfoObjects</code> extension method is an <code>IEnumerable&lt;T&gt;</code> and by the generic type constraint, <code>T</code> must implement <code>ITest</code>. </p>

<p><strong>Why is then the receiver not accepted</strong>? My guess is the covariance of the <code>IEnumerable&lt;T&gt;</code> but I am not sure.</p>

<p>If I change <code>ToInfoObjects</code> to receive <code>IEnumerable&lt;T&gt; where T : ITest</code>, then everything is ok.</p>
