Self-type does not conform to base class

Viewed 2490

Using the following code:

trait Hello[B <: Baz[_, _]]
trait World[F <: Foo] { self: Hello[Baz[F, _]] =>

  def foo: F

}
trait Baz[F <: Foo, B <: Bar]
trait Foo
trait Bar

case class BasicHello() extends Hello[BasicBaz] with World[BasicFoo]
case class BasicBaz() extends Baz[BasicFoo, BasicBar]
case class BasicFoo() extends Foo
case class BasicBar() extends Bar

I get the following error in my IDE at the BasicHello case class:

Illegal inheritance, self-type BasicHello does not conform to Hello[Baz[F, _]]

I have no clue why the compiler doesn't allow this since BasicHello extends Hello[BasicBaz], which in its turn extends Baz[BasicFoo, BasicBar]. The type of BasicHello should be Hello[Baz[Foo, Bar]] which is exactly what the World mix-in requires. Is there some hierarchical property I'm missing of self-types?

1 Answers
Related