Question why class objects are never inherited

Hello,

I saw this comment “note that class objects are never inherited” here the Kotlin docs:

class D : C()

val d = D.create() // Error: no class object for D


I was a bit surprised by this and tried it out in Scala which revealed that class objects in Scala can also not inherited. For someone from the Smalltalk/Java camp this is a bit unusual. I understand that a class object can inherit from a different class than the class it is surrounded by. This is some additional expressiveness compared to class vars/methods aka static vars/methods.

But I still don’t really understand the rational behind not being able to inherit vars and methods defined in a class object. Searching the Internet didn’t reveal much that was insightful. Could someone drop me a hint what’s the reason for this?

Thanks, Oliver

First off, static methods being inherited is a great source of trouble in Java (see the Java puzzlers book)

Then, as you rightly say, class objects can inherit from classes, and as there can be only one superclass, they can not inherit from the class object of the superclass.