I have some case classes that extend a common superclass and I'd like to access fields from the superclass using productElement method (I've tryed to declare base class as a case class but I get a frightening warning about the dangers of inheritance of case classes and yet doesn't work).
I can imagine some solution like this:
abstract class A(a: Int) extends Product { def productArity = 1 def productElement(n: Int) = if (n == 0) a else throw new IndexOutOfBoundsException } case class B(b: Int) extends A(1) { def productArity = super.productArity + 1 def productElement(n: Int) = if (n < super.productArity) super.productElement(n) else .... } but it was getting so ugly that I can't even finish.
Does anybody know a better solution?
Aanabstract case class?