Why is the error below? How to workaround it?
EDIT: I assumed that since A and B compile to (interface,class) pairs, it's a matter of choosing the right static method call to implement when compiling C. I would expect the priority to be according to order.
scala> trait A {def hi = println("A")}
defined trait Ascala> trait A {def hi = println("A")}
defined trait A
scala> trait B {def hi = println("B")}
defined trait B
scala> class C extends B with A
:6: error: error overriding method hi in trait B of type => Unit;
method hi in trait A of type => Unit needs `override' modifier
class C extends B with A
scala> trait A {override def hi = println("A")}
:4: error: method hi overrides nothing
trait A {override def hi = println("A")}
EDIT: note that in Ruby this works well:
>> module B; def hi; puts 'B'; end; end => nil >> module A; def hi; puts 'A'; end; end => nil >> class C; include A; include B; end => C >> c = C.new => # >> c.hi B => nil