Accepted answer

Companion objects are objects like any other. In particular, they can extend traits as well. So you could have a trait for this secondary behavior.

trait Stage { ... }
trait StageCompanion {
  def run(): Unit

class Write extends Stage { ... }
object Write extends StageCompanion {
  override def run() = { ... }

And, of course, in your particular case, such a trait already exists: the Java interface Runnable. So you could simply

object Write extends Runnable { ... }

Related Query

More Query from same tag