Why invariant generic type parameterized with subclass of upper bounds fails to conform? <p>Given:</p> <pre><code>class Invar[T] trait ExtendsAnyref extends AnyRef def f(a: Invar[ExtendsAnyref]) = {} </code></pre> <p>The following is erroneous</p> <pre><code>scala&gt; val x: Function1[Invar[_ &lt;: AnyRef], Unit] = f &lt;console&gt;:13: error: type mismatch; found : Invar[ExtendsAnyref] =&gt; Unit required: Invar[_ &lt;: AnyRef] =&gt; Unit val x: Function1[Invar[_ &lt;: AnyRef], Unit] = f ^ </code></pre> <p>Why?</p> <p>I understand that in Scala, generic types have by default nonvariant subtyping. Thus, in the context of this example, instances of <code>Invar</code> with different type parameters would never be in a subtype relationship with each other. So an <code>Invar[ExtendsAnyref]</code> would not be usable as a <code>Invar[AnyRef]</code>.</p> <p>But I am confused about the meaning of <code>_ &lt;: AnyRef</code> which I understood to mean "some type below <code>AnyRef</code> in the type hierarchy." <code>ExtendsAnyref</code> is some type below <code>AnyRef</code> in the type hierarchy, so I would expect <code>Invar[ExtendsAnyref]</code> to conform to <code>Invar[_ &lt;: AnyRef]</code>.</p> <p>I understand that function objects are contravariant in their input-parameter types, but since I use <code>Invar[_ &lt;: AnyRef]</code> rather than <code>Invar[AnyRef]</code> I understood, apparently incorrectly, the use of the upper bounds would have the meaning "<code>Invar</code> parameterized with <code>Anyref</code> or any extension thereof."</p> <p>What am I missing?</p>