score:17

Accepted answer

Yes, you do, just as you state. There's access, and there's scope -- what companion class/objects have is access, not scope.

It's like declaring something public vs private -- it doesn't bring those members into everyone's scope, just give them access to it.

score:3

Yes (and I want my 15 points for that!)

But to expand, their scopes do not overlap, so the import is necessary.

score:4

"Can access private members" means that the following works:

object Foo {
  private def bar = 4
}

class Foo {
  def foo = Foo.bar
}

Related Query

More Query from same tag