Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.