Consider the following simple example:
trait Foo {
type Bar
}
class Baz extends Foo // <-- no compile error
I don't understand how the last statement compiles when clearly type Bar
wasn't implemented by concrete type class Baz
(FWIW, marking it final
also produced the same result).
And it only fails to compile when I actually try access the type Bar
through path-dependent type.
val baz: new Baz
val bazBar: baz.Bar = new baz.Bar // <-- compile error
What's even more interesting is that at type-level, signature actually does compile but it only fails when I access at value-level through new baz.Bar
.
In other words, the following does compile:
val bazBar: baz.Bar = ???
This is quite unintuitive as it deviates from the way of other abstract members.
Why does unimplemented abstract type not raise compile error? Am I missing something?