« Return to Thread: self type is not inherited

Re: [scala] self type is not inherited

by gerry xiao :: Rate this Message:

Reply to Author | View in Thread

Trait B's self type is A, An Instances of B should also be instances of A,but C,D,E couldn't assure this, so you need redeclare it;
it seems self type can't be inherited


gerry


2008/10/12 Mushtaq Ahmed <mushtaq.a@...>

Given that,

trait A
trait B {this: A =>}

Each time we extend B, we need to explicitly specify the self type as A:

trait C extends B {this: A =>}
trait D extends B {this: A =>}
trait E extends B {this: A =>}

Can't this repetition be avoided? Shouldn't self type of C, D and E default
to A unless explicitly specified otherwise? Currently, this gives the
following error:

trait F extends B
error: illegal inheritance; self-type F does not conform to B's selftype B
with A

Regards,
Mushtaq
--
View this message in context: http://www.nabble.com/self-type-is-not-inherited-tp19934242p19934242.html
Sent from the Scala mailing list archive at Nabble.com.


 « Return to Thread: self type is not inherited