Ответ 1
Кажется, что одноэлементные типы без членов эквивалентны как-то здесь. Возможно, это ошибка (вы подали билет). Например, следующее создает ошибку времени выполнения:
sealed trait Parent
case object Boy extends Parent
case object Girl extends Parent
trait HasGirl {
val x: Girl.type
}
case class Thing(x: Boy.type) extends HasGirl {
def y: Girl.type = (this: HasGirl).x
}
val t = Thing(Boy)
t.y // ClassCastException !
Если я добавлю элемент, вы получите ошибку времени компиляции:
sealed trait Parent
case object Boy extends Parent
case object Girl extends Parent { def hello = 1234 }
trait HasGirl {
val x: Girl.type
}
case class Thing(x: Boy.type) extends HasGirl
<console>:57: error: overriding value x in trait HasGirl of type Girl.type; value x has incompatible type case class Thing(x: Boy.type) extends HasGirl ^