I just hit a bug in scalac [1] which is caused by using the still null value of a field during the initialiazation of that field. Essentially, it is the same as the following:
~> cat test.scala
object A { val a: AnyRef = { println("a = " + a); ""} }
A.a
~> scala test.scala
a = null
This can be the source of subtle bugs. My mental model is that using vals rather than vars avoids such problems. Would it be feasible to add a -X option to fail fast in this case? I guess this would involve some extra bookkeeping about which fields are currently being initialized, similar to the handling of lazy vals.
-jason
[1]
https://lampsvn.epfl.ch/trac/scala/ticket/2493