Yes they can, a trait that extends a class limits what classes can extend this trait , namely, all classes that mix in that trait should extend this class .
scala> class Foo defined class Foo scala> trait FooTrait extends Foo defined trait FooTrait scala> val good = new Foo with FooTrait good: Foo with FooTrait = $anon$1@773d3f62 scala> class Bar defined class Bar scala> val bad = new Bar with FooTrait <console>:10: error: illegal inheritance; superclass Bar is not a subclass of the superclass Foo of the mixin trait FooTrait val bad = new Bar with FooTrait ^
adelbertc Oct 12 '12 at 8:23 2012-10-12 08:23
source share