When he says that Scala doesn't support multiple inheritance, then he refers to inheriting a method implementation multiple times. Of course, you can implement multiple interfaces/traits in a class, and they can even define the same method, but you do not get a conflict between the different implementations due to trait linearization.
In general, if you have a class C1
with a method f()
and a class C2
also with a method f()
, then multiple inheritance means you can somehow inherit both implementations of f()
. This can lead to various problems, which Scala resolves by only letting you inherit from a single class and in case of multiple traits by selecting one implementation based on the order of the traits.
As for Nothing
things are really simple, because nothing has no attributes or methods defined. So you cannot have any inheritance conflicts. But I assume that most of your surprise comes from a different understanding of multiple inheritance.
Once you understand that trait linearization effectively eliminates any ambiguity of the inheritance, and that we do not refer to inheriting from multiple traits as multiple inheritance due to that, then you should be fine.
As to how this is realized: the compiler is eventually responsible for this. See the Scala language specification section 3.5.2 conformance, which amongst other properties includes:
For every type constructor T (with any number of type parameters), scala.Nothing <: T <: scala.Any.
Or in other words, if you want to implement a compiler correctly, it has to handle Nothing
as a subtype of everything by specification. For obvious reasons, Nothing
is not defined to extend from all classes loaded into the system, but the relevance of defining Nothing
as subtype is limited to all places, where subtyping is relevant.
An important point here is that there exists no instance of type Nothing
, hence, its treatment is strictly limited to type-checking, which is all in the realm of the compiler.
Nothing
is a subclass of every other class. It says that it is a subtype of every other type.