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 T2
has a contract that says: If you inherit from me, you should also inherit from T1
.
object O extends T2 with T1
You would then probably get an error that type S
is not defined. Which is a good thing since it's used in the definition of CLS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With