Rules of inheritance hierarchies

Before looking into linearization rules, we need to be clear on some inheritance rules in Scala:

  • In Java, even if a class does not explicitly extend another one, its superclass will be java.lang.Object. The same stands for Scala, and the equivalent base is AnyRef.
  • There is a similarity between directly extending a trait and extending the trait superclass and mixing the trait in using the with keyword.
In older Scala versions, there was another type called ScalaObject that was implicitly added to all traits and classes.

Using those rules, we can always get to a canonical form for all traits and classes, where the base class is specified using extends and then all traits are added using the with keyword.