title: Scala and forward references
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7762838/scala-forward-references-why-does-this-code-compile">Scala: forward references - why does this code compile?</a>  </p>
  </blockquote>
  
  
  
  <pre><code>object Omg {
  
    class A
  
    class B(val a: A)
  
    private val b = new B(a)
  
    private val a = new A
  
    def main(args: Array[String]) {
      println(b.a)
    }
  
  }
  </code></pre>
  
  <p>the following code prints "null". In java. similar construction doesn't compile because of invalid forward reference. The question is - why does it compile well in Scala? Is that by design, described in SLS or simply bug in 2.9.1?</p>