Question about companions and inheritance


#1

Say I have three classes (A, B : A, C : A and D). Say further that class A has a companion object that extends class D, and B and C have no explicitly defined companion object.

I’m unclear as to what to expect of the companions of classes B and C. Does A.companion == B.companion and/or B.companion === C.companion hold true? Or maybe companions of child classes always need to be defined? I feel this should be clarified in the official documentation.


#2

The super types of a class do not affect companion objects at all. Also, if a class does not define a companion object, it has no companion object.