title: Scala overriding a non-abstract def with a var
body: <p>In Scala I can do this:</p>
  
  <pre><code>trait SomeTrait {
    protected def foo: String
  }
  
  class Wibble extends SomeTrait {
    protected var foo = "Hello"
  }
  </code></pre>
  
  <p>But I cannot do the same thing where I provide a default definition for <code>foo</code></p>
  
  <pre><code>trait SomeTrait {
    protected def foo: String = "World"
  }
  
  class Wibble extends SomeTrait {
    protected var foo = "Hello" //complains about lack of override modifier
  
    override protected var foo = "Hello" //complains "method foo_ overrides nothing"
  }
  </code></pre>
  
  <p>Why can't I do this?</p>
  
  <p><em>EDIT: After a conversation on the scala-users mailing list, I have <a href="https://lampsvn.epfl.ch/trac/scala/ticket/2338" rel="noreferrer"><strong>raised this in trac</strong></a></em></p>