When running the following code,
object Foo {
val hoge = Hoge
}
sealed abstract class Hoge(
val foo: Foo.type = Foo
)
object Hoge {
case object A extends Hoge
case object B extends Hoge
case object C extends Hoge
val values = IndexedSeq(A, B, C)
}
object Main extends App {
println(Hoge.B)
println(Hoge.A)
println(Hoge.C)
println(Hoge.values)
}
the output is
B
A
C
Vector(A, null, C)
but changing the main to
object Main extends App {
println(Hoge.values)
}
results in
Vector(A, B, C)
What exactly is happening under the hood that causes this behaviour?