dveim
dveim

Reputation: 3482

Access companion object from base trait

If I define a trait, I can access successor's fields. But what if one of those fields is in companion object (e.g. for speed, as static member), can I access it too?

Is there a relationship between TheTrait object and TheSuccessor object, as with TheTrait trait and TheSuccessor class?

Upvotes: 1

Views: 177

Answers (1)

PhilBa
PhilBa

Reputation: 732

As far as I can tell you cant. You could either let the companion object implement the trait, or maybe define an abstract method in the trait. Implementing classes could then provide access to the companion object by implementing the method.

Upvotes: 1

Related Questions