Ignoring the predefined universal bases, the Scala trait linearizations are D1, B2, B1, A and D2, B1, B2, A. The rightmost mixed-in trait is searched first, while the shared base occurs only once.
The output is:
h in B2, g in B1, f in A
h in B1, g in B2, f in A
For D1, h is the B2 implementation. Its super.g continues after B2 to B1.g; that method's super.f continues after B1 to A.f. The second line follows the reversed mixin order. In particular, a trait's unqualified super is interpreted in the concrete receiver's linearization, not by assuming the trait always sees only its textual parent.[ref]

Articles by others on the same topic (0)

There are currently no matching articles.