Co/contravariance with Func<in T1, out TResult> as parameter
<p>Assume I have an interface such as</p>

<pre><code>public interface IInterface&lt;in TIn, out TOut&gt; {
  IInterface&lt;TIn, TOut&gt; DoSomething(TIn input);
}
</code></pre>

<p><code>TIn</code> being <em>contra</em>-variant, and <code>TOut</code> being <em>co</em>-variant.</p>

<p>Now, I want callers to be able to specify some function to be executed on the input's value, so naïvely I would add the following method to the interface:</p>

<pre><code>IInterface&lt;TIn, TOut&gt; DoSomethingWithFunc(Func&lt;TIn, TOut&gt; func);
</code></pre>

<p>which … does not work. <code>TIn</code> is now required to be covariant, and <code>TOut</code> contravariant.</p>

<p>I understand, that I cannot use covariant generic types as input for methods, but I thought I could use them in a nested generic type which itself specifies the variance (<code>Func&lt;in T1, out TResult&gt;</code>).</p>

<p>I tried creating a new delegate type with co-/contravariant types and change the interface to accept an argument of this type, to no avail (same error).</p>

<pre><code>public delegate TOut F&lt;in TDlgIn, out TDlgOut&gt;(TDlgIn input);

public interface IInterface&lt;in TIn, out TOut&gt; {
  IInterface&lt;TIn, TOut&gt; DoSomethingWithFunc(F&lt;TIn, TOut&gt; func);
}
</code></pre>

<p>I there a way I can make the compiler happy? <strong>Is this even possible (for instance with other nested types, or additional generic arguments)? If not, why not?</strong></p>