I’m confused by the following code:
trait T1 {
type S
}
trait T2 {
self: T1 =>
case class ClS(s: S)
}
object O extends T2 {
}
It gives out the following error message:
illegal inheritance; tests.O.type does not conform to tests.T2’s
selftype tests.T2 with tests.T1
What’s going wrong? the reason that I extend O with T2 is that I want to reference the class CLS in O, how can I achieve that?
trait T2has a contract that says: If you inherit from me, you should also inherit fromT1.You would then probably get an error that
type Sis not defined. Which is a good thing since it’s used in the definition ofCLS