title: Can companion object extend some trait different from companion class?
body: <p>I've always used companion objects just as they should be: having some class or trait, I've defined the object with the same class name in the same file.
  But I'm trying at the moment to factor out some common functionality that few companion objects share and wonder if it is safe to have something like this:</p>
  
  <pre><code>trait Label {
    def label: String
  }
  
  trait InstancesMap[T &lt;: Label] {
    private var instances = Map.empty[String, T]
    def init(instance: T): T = {
      instances += (instance.label -&gt; instance)
      instance
    }
    def byLabel(label: String): T = instances(label)
  }
  
  case class EventStatus(label: String) extends Label
  
  object EventStatus extends InstancesMap[EventStatus] {
    val DRAFT = init(EventStatus("draft"))
    val PUBLISHED = init(EventStatus("published"))
  }
  </code></pre>
  
  <p>I am not sure if it is safe for case class companion object to extend some other trait. It compiles and works fine, but would be great to hear some opinions.</p>