In Scala, linearizations are listed from left to right where the right-most class is the most general, for example, AnyRef. While doing linearization, Any is also added to the hierarchy list. This, combined with the rule that any class must include the linearization of its superclass, means that the superclass linearization will appear as a suffix of the class linearization.
Let's see an example with some really simple classes:
class Animal extends AnyRefclass Dog extends Animal
The linearization of these two classes will be, respectively:
Animal -> AnyRef -> AnyDog -> Animal -> AnyRef -> Any
Now, let's try and formalize an algorithm that describes how a linearization is calculated:
- Start with the following class ...