title: Can I perform matching on a type parameter in Scala to see if it implements a trait?
body: <p>I would like to have a method which returns a class of a certain type, but I want the method to behave differently depending on whether or not the class extends a particular trait as follows: </p>
  
  <pre>
  <code>
  case class ClassA extends TraitA
  case class ClassB extends TraitB
  case class ClassC extends TraitA
  ...
  def myfunc[T]():T = {
    T match {
      case TraitA => // return new T in a particular way 
      case TraitB => // ditto
    }
  }
  </code>
  </pre>
  
  <p>Is this possible, or am I going about it the wrong way?</p>
  
  <p>Thanks</p>