Skip to content

Commit da773fb

Browse files
committed
Extend test to verify initialization order
Verify that the initilialization order described in #640 is correctly implemented.
1 parent d19c30c commit da773fb

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tests/run/traitParams.scala

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1+
object State {
2+
var s: Int = 0
3+
}
4+
15
trait T(x: Int, val y: Int) {
26
def f = x
37
}
48

59
trait U extends T {
10+
State.s += 1
611
override def f = super.f + y
712
}
13+
import State._
14+
class C(x: Int) extends U with T(x, x * x + s)
15+
class C2(x: Int) extends T(x, x * x + s) with U
816

9-
class C(x: Int) extends U with T(x, x * x)
10-
11-
class D extends C(10) with T {
12-
13-
}
17+
class D extends C(10) with T
18+
class D2 extends C2(10) with T
1419

1520
object Test {
16-
def main(args: Array[String]): Unit =
21+
def main(args: Array[String]): Unit = {
1722
assert(new D().f == 110)
23+
assert(new D2().f == 111)
24+
}
1825
}
1926

0 commit comments

Comments
 (0)