Ответ 1
Да, они могут, a trait
, который расширяет class
, ограничивает то, что classes
может расширить этот trait
, а именно, все classes
, которые смешивают в том, что trait
должен расширять этот 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 = [email protected]
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
^