title: Scala Trait type mismatch
body: <p>I have some Kafka Channel hierarchy that I am using in my project: </p>
  
  <p>My base trait is:</p>
  
  <pre><code>trait SendChannel[A, B] extends CommunicationChannel {
    def send(data:A): B
  }
  </code></pre>
  
  <p>Now I have a common kafka send Channel like </p>
  
  <pre><code>trait CommonKafkaSendChannel[A, B, Return] extends SendChannel[A, Return] {
  val channelProps: KafkaSendChannelProperties
  val kafkaProducer: Producer[String, B]
   override def close(): Unit = kafkaProducer.close()
  }
  </code></pre>
  
  <p>Now there are 2 variants of CommanKafkaSendChannel, one is with callback and one is with Future:</p>
  
  <pre><code>trait KafkaSendChannelWithFuture[A, B] extends CommonKafkaSendChannel[A, B, Future[RecordMetadata]] {
  override def send(data: A): Future[RecordMetadata] = Future {
    kafkaProducer.send(new ProducerRecord[String, B](channelProps.topic)).get
  }
  }
  </code></pre>
  
  <p><code>KafkaSendChannelWithCallback</code> definition:</p>
  
  <pre><code>object KafkaSendChannelWithCallback {
  
  def apply[A, B](oChannelProps: KafkaSendChannelProperties,
                oKafkaProducer: Producer[String, B],
                oCallback: Callback): KafkaSendChannelWithCallback[A, B] =
  new KafkaSendChannelWithCallback[A,B] {
    override val channelProps: KafkaSendChannelProperties = oChannelProps
    override val kafkaProducer: Producer[String, B] = oKafkaProducer
    override val callback: Callback = oCallback
  }
  }
  
  trait KafkaSendChannelWithCallback[A, B] extends CommonKafkaSendChannel[A, B, Unit] {
  
    val callback: Callback
  
  override def send(data: A): Unit =
  kafkaProducer.send(new ProducerRecord[String, B](channelProps.topic), callback)
  }
  </code></pre>
  
  <p>Now based on the configuration value I select the proper type of channel on run time like below. I am creating actor with right type of channel which will send the data to kafka: </p>
  
  <pre><code>  val sendChannel = kafkaChannel.channel(config, actorSystem).fold(
      error =&gt; {
        logger.error("Exception while instantiating the KafkaSendChannel")
        throw error
      },
      success =&gt; success
    )
  
  actor = actorSystem.actorOf(IngestionActor.props(config, sendChannel), name = ACTOR_NAME)
  </code></pre>
  
  <p>Actor definition: </p>
  
  <pre><code>object IngestionRouterActor {
    def props[V](config: Config, sendChannel: SendChannel[V, Unit]): Props =
  Props(classOf[IngestionActor[V]], config, sendChannel)
  }
  </code></pre>
  
  <p>The problem is when I use <code>KafkaSendChannelWithCallback</code> my code compiles properly however when I use <code>KafkaSendChannelWithFuture</code> it gives me below error on <code>actor =</code> declaration:</p>
  
  <blockquote>
    <p>[error]IngestionActor.scala:32: pattern type is incompatible with expected type;
    [error]  found   : KafkaSendChannelWithFuture[String,V]
    [error]  required: SendChannel[V,Unit]</p>
  </blockquote>
  
  <p>As both the channel definitions are extended from <code>SendChannel</code>, this code should have compiled without any error. I am not sure why it is not compiling. Thanks</p>