title: Recursive value xxx needs type in Scala
body: <p>I am confused about why Scala is complaining about this code. I have two classes which depend on each other. When I try to create a new instance of <code>A</code> without a type declaration, the code won't compile.</p>
  
  <pre class="lang-scala prettyprint-override"><code>  class A( b:B ) {
  
    }
  
    class B( a:A ){
  
    }
  
    val y = new A ( new B( y ) ); // gives recursive value y needs type
  
    val z:A = new A ( new B( y ) ); // ok
  </code></pre>
  
  <p>Why does the compiler does not know the type of <code>y</code> when I declared as <code>new A</code>
  ?</p>