Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala package object does not bring companion object into scope?

Tags:

scala

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

}

Looks like I am misunderstanding the point of the package object since I was under the belief that the preceding would bring the companion object Sync into scope.

Sync is a top-level object under package engine.logic.sync.

Here is how I am accessing 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's the workaround and how did I mess up my packaging?

Thanks!

like image 491
crockpotveggies Avatar asked Sep 17 '12 16:09

crockpotveggies


1 Answers

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

val Sync = engine.logic.sync.Sync
like image 171
Sergey Passichenko Avatar answered Nov 15 '22 03:11

Sergey Passichenko