title: Stackoverflow when use bufferedInputStream as a trait in scala
body: <p>I am trying to solve a problem given by the Book "Scala for the Impatient", which asked to implement java's BufferedInputStream as a trait. Here is my implementation,</p>
  
  <pre><code>trait Buffering {           
      this:InputStream =&gt;
          private[this] val bis = {
              new JavaBufferedInputStream(this)
          }
          override def read = bis.read
          override def read(byte:Array[Byte], off:Int, len:Int) = bis.read(byte, off, len)
          override def available = bis.available
          override def close() {
              bis.close
          }
          override def skip(n:Long) = bis.skip(n)
  }
  
  def main(args:Array[String]) {
      val bfis = new FileInputStream(new File("foo.txt")) with Buffering
      println(bfis.read)
      bfis.close
  }
  </code></pre>
  
  <p>But this give me a java stackoverflow error, so what's wrong with it? Thanks!</p>