Scala – How to avoid scala’s case class default toString function being overridden

case-classscala

Scala case class has a default toString function. But when this case class extends a trait with an existing toString() function, it will be rendered useless. How can I prevent this situation?

Best Answer

OK here is the easist answer:

override def toString = ScalaRunTime._toString(this)

end of story:)