Skip to content

Commit 303e263

Browse files
committed
Add a test for trait initialization.
1 parent 1aa1d75 commit 303e263

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/run/traits-initialization.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
trait A {
2+
var str = ""
3+
str = "a"
4+
val s = str += 'A'
5+
str += '1'
6+
}
7+
8+
trait B extends A {
9+
str += 'b'
10+
override val s = str += 'B'
11+
str += '2'
12+
}
13+
14+
class D extends A {
15+
str += 'd'
16+
override val s = str += 'D'
17+
str += '3'
18+
}
19+
20+
object Test extends D with B {
21+
// should only have 2 fields
22+
str += 'E'
23+
def main(args: Array[String]) = assert(str == "aA1dD3bB2E4")
24+
str += '4'
25+
}

0 commit comments

Comments
 (0)