In the following example, I can't get to hide update
from public exposure:
trait Order {
sealed trait EntryOption {
private[Order] def update(e: EntryOption): Unit
}
private case object EmptyEntry extends EntryOption {
def update(e: EntryOption) = ()
}
trait Entry extends EntryOption
def test(a: Entry, b: EntryOption): Unit = a.update(b)
}
It fails to compile with "error: object creation impossible, since method $line12$$read$Order$^date in trait EntryOption of type (e: Order.this.EntryOption)Unit is not defined
" – whatever that is supposed to be (compiler bug?). I tried the following without success:
update
in EmptyEntry
private[Order]
protected
– this breaks method test
The goal is to have EntryOption
's update
inaccessible from outside Order
.
EDIT
If I tentatively change trait Order
to object Order
it compiles, indicating a potential compiler bug?
A stupid work-around:
trait Order {
sealed trait EntryOption {
private[Order] def update(e: EntryOption): Unit
}
private sealed trait ScalaChokes extends EntryOption {
private[Order] final def update(e: EntryOption) = ()
}
private case object EmptyEntry extends ScalaChokes
trait Entry extends EntryOption
}
Should I file a bug?