- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
trait vals initialization order
Tue, 2009-01-13, 16:12
Hello again (it seens i always send emails to complain, but what can i do?)
I think ive found a bug, but since i couldnt find it in Trac, it might
just be intentional
consider a simple trait:
trait A {
val list: List[String] //any non "constant" value
val first = list.firstOption //any method will do
}
all implementations of this trait throws NullPointerException - at
least in 2.7.2-final and 2.7.3-RC2. Is this intended? If not, it
happens like this because the trait $init method is called before the
assignment for the generated list field
thanks for the attention