title: Scala: How can I do inheritance between classes and companion objects
body: <p>I am trying to setup a case class hierarchy in Scala that uses companion objects. Each case class has a companion object that has a implicit method, however, I would like to make a abstract class that case classes can extend. The problem is that I have no way to make the abstract class's companion object abstract as well. Below is the code, I currently have:</p>
  
  <pre><code>abstract class Call {}
  
  abstract class ArgumentsCall extends Call {}
  
  trait Jsonable[T] {
          implicit def convert: CodecJson[T]
  }
  case class VersionCall(version:String) extends Call  //{"version": "0.1"}
  object VersionCall {
          implicit def convert: CodecJson[VersionCall] = casecodec1(VersionCall.apply, VersionCall.unapply)("version")
  }
  
  case class CommandCall(command:String,arguments:ArgumentsCall) extends Call //{"command": "pcap-file", "arguments": {"output-dir": "/opt/suricata_out/1", "filename": "/opt/suricata_fifo/1"}}
  object CommandCall {
          implicit def convert: CodecJson[CommandCall] = casecodec2(CommandCall.apply, CommandCall.unapply)("command","arguments")
  }
  case class PcapCall(outputDir:String,filename:String) extends ArgumentsCall
  object PcapCall extends ArgumentsCall {
          implicit def convert: CodecJson[PcapCall] = casecodec2(PcapCall.apply, PcapCall.unapply)("output-dir","filename")
  }
  
  case class Response(returnS:String, message:Option[String])
  object Response {
          implicit def convert: CodecJson[Response] = casecodec2(Response.apply, Response.unapply)("return","message")
  }
  </code></pre>
  
  <p>The compiler is unable to determine that ArgumentsCall or it's child would have the "implicit def convert:CodecJson".
  Here is the actual compiler error:</p>
  
  <pre><code>[error] /blah/src/main/scala/helpers/JsonApi.scala:24: could not find implicit value for evidence parameter of type argonaut.EncodeJson[helpers.ArgumentsCall]
  [error]     implicit def convert: CodecJson[CommandCall] = casecodec2(CommandCall.apply, CommandCall.unapply)("command","arguments")
  [error]                                                                                                      ^
  [error] one error found
  [error] (compile:compile) Compilation failed
  </code></pre>
  
  <p>Can someone please give me a good way to reason about class/companion objects and how to do inheritance with them? I have a feeling I have a fundamental misunderstanding about how to implement this. </p>
  
  <p>Thanks</p>