Scala package object does not bring companion object in scope?

Developed a small package object that looks like this:

package object logic {

  type Chat = engine.logic.chat.Chat
  type History = engine.logic.history.History
  type Meta = engine.logic.meta.Meta
  type Notification = engine.logic.notification.Notification
  type Service = engine.logic.service.Service
  type State = engine.logic.state.State
  type Sync = engine.logic.sync.Sync

}

It seems that I do not understand the point of the package object, since I was convinced that the previous one would bring the companion object Syncinto scope.

Syncis a top level object under package engine.logic.sync.

This is how I refer to it:

engine.logic.Sync.aMemberDef(var: String)

However, the compiler throws an error object Sync is not a member of package engine.logic. So what is the workaround and how did I mess up my packaging?

Thank!

+5
source share
1 answer

If you want to create an instance alias, just use val:

val Sync = engine.logic.sync.Sync
+6
source

All Articles