| [#120] | project: compiler | priority: medium | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Matthias | Michel | fixed | 2003-09-10 14:49:58.0 | |
| subject | Evaluation order of mixin constructor parameters | |||
| code |
class A(x: Int) {
System.out.println("A");
}
class B(x: Int) {
System.out.println("B");
}
class C(x: Int) with A(O.print("one", 1)) with B(O.print("two", 2)) {
System.out.println("C");
}
object O {
def print[A](str: String, res: A): A = {
System.out.println(str); res
}
def main(args: Array[String]) = {
val c = new C(1);
}
} |
|||
| what happened | The program compiles and runs. The output indicates that the order in which the constructor parameters of the two mixins of class C are evaluated is wrong. Here's the output:two B one A CSurprisingly, it is possible to change the evaluation order by replacing the first "with" with an "extends" (in class C). Then, the evaluation order is the following:one A two B C |
|||
| what expected | The evaluation order should be the same in both cases (left to right). | |||
| [back to overview] | ||||
| Michel edited on 2003-09-30 13:13:18.0 |