Skip to content

Instantly share code, notes, and snippets.

@fedesilva
Created January 4, 2014 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedesilva/d9e636695484d8eaddea to your computer and use it in GitHub Desktop.
Save fedesilva/d9e636695484d8eaddea to your computer and use it in GitHub Desktop.
Case Class Inheritance
trait Base1
case class A1(s:String) extends Base1
case class B1(s:String) extends Base1
abstract class Base2(val attr: String)
case class A2(val attr:String) extends Base2(attr)
case class B2(val attr:String) extends Base2(attr)
case object O2 extends Base2("literal")
// This is not right
// case object O3 extends A1("literal2")
// > case object O3 has case ancestor Codebrew.A1, but case-to-case inheritance is prohibited. To overcome this limitation, use
// > extractors to pattern match on non-leaf nodes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment