code |
Section 5.1 talks about "with ScalaObject" being added implicitly. This may be confusing as mentioning "with ScalaObject" explicitly, as in the example code below, leads to compile errors:-
Example 5.1.3 (without the "..." )
abstract class AbsIterator extends AnyRef with ScalaObject { }
The code is rejected by the compiler:-
:30: error: trait ScalaObject is inherited twice
abstract class AbsIterator extends AnyRef with ScalaObject { }
^
:30: error: trait ScalaObject is inherited twice
abstract class AbsIterator extends AnyRef with ScalaObject { }
^
two errors found
"
Example 5.1.6 Consider the class definitions
class A { def f: Int = 1 ; def g: Int = 2 ; def h: Int = 3 }
abstract class B { def f: Int = 4 ; def g: Int }
abstract class C extends A with B { def h: Int }
"
"trait B" is needed instead of "abstract class B"
The current code is rejected by the compiler:-
error: class B needs to be a trait be mixed in
abstract class C extends A with B { def h: Int }
^
one error found
|