Ich bin fest versucht Scala zu verstehen, erlaubt es nicht, die folgenden:Scala: val mit flüchtigen Typ überwiegendes def mit nichtflüchtigen Typ
trait WhatsWrong {
type Foo
trait HasFoo {
def foo: Foo
}
type Foo2 = Foo with HasFoo2
trait HasFoo2 extends HasFoo {
override val foo: Foo2 // <-- error here
// override def foo: Foo2 // <-- this works though
}
}
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
override val foo: WhatsWrong.this.Foo2
Warum Foo2
einen flüchtigen Typ ist?
Ich denke du hast einen Tippfehler: "Foo ~~ 2 ~~ ist nicht flüchtig (weil keiner von 1.-3. Gilt)". Sieht anders aus, danke! – eprst
ja, du hast recht von grund, korrigiert –