title: Scala: val with volatile type overriding def with non-volatile type
body: <p>I'm stuck trying to understand Scala doesn't allow the following: </p>
  
  <pre><code>trait WhatsWrong {
    type Foo
  
    trait HasFoo {
      def foo: Foo
    }
  
    type Foo2 = Foo with HasFoo2
  
    trait HasFoo2 extends HasFoo {
      override val foo: Foo2 // &lt;-- error here
   // override def foo: Foo2 // &lt;-- this works though
    }
  }
  </code></pre>
  
  <blockquote>
    <p>Error: overriding method foo in trait HasFoo of type => WhatsWrong.this.Foo;
     value foo has a volatile type; cannot override a member with non-volatile type<br>
    <code>override val foo: WhatsWrong.this.Foo2</code></p>
  </blockquote>
  
  <p>Why <code>Foo2</code> is a volatile type?</p>