title: Understanding variance in Scala
body: <p>I have following code:</p>
  
  <pre><code> trait DestinationBinding[T &lt;: Actor] {
  def resolve(implicit context: ActorContext, manifest: scala.reflect.ClassTag[T]): ActorRef = {
    println(s"creating destination binding actor of:$name")
    context.actorOf(Props[T], name)
  }
  
  def name: String = manifest.runtimeClass.getSimpleName
  }
  </code></pre>
  
  <p>That is basically just a simple way to create actors. And following some implementations.</p>
  
  <pre><code>case class BlackHoleBinding extends DestinationBinding[BlackHoleDeliveryAgent]
  </code></pre>
  
  <p>Where <code>BlackHoleDeliveryAgent</code> is an Actor</p>
  
  <p>There are also some messages:</p>
  
  <pre><code>case class Delivery[T &lt;: Actor](message: Any, binding: DestinationBinding[T])
  </code></pre>
  
  <p>Problem appears when I want to pattern match over those:</p>
  
  <pre><code>Note: com.elemica.erc.BlackHoleDeliveryAgent &lt;: akka.actor.Actor (and BlackHoleBinding &lt;:    DestinationBinding[BlackHoleDeliveryAgent]), but trait    DestinationBinding is invariant in type T.
  [error] You may wish to define T as +T instead. (SLS 4.5)
  [error]     case Delivery(message, binding: BlackHoleBinding) =&gt; {
  </code></pre>