aboutsummaryrefslogtreecommitdiff
path: root/tests/run/traitInit.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2015-05-16 22:43:53 +0200
committerGuillaume Martres <smarter@ubuntu.com>2015-05-21 16:29:28 +0200
commitc48badad54f90047f690d02e8af80153c6634412 (patch)
tree6a0de36f10b33f618203775254460d380982e486 /tests/run/traitInit.scala
parentbf81fb62084f9e04e43906396c3ac5e307caca63 (diff)
downloaddotty-c48badad54f90047f690d02e8af80153c6634412.tar.gz
dotty-c48badad54f90047f690d02e8af80153c6634412.tar.bz2
dotty-c48badad54f90047f690d02e8af80153c6634412.zip
Mixin: fix the initialization of traits
Before this commit, the following code: trait Hello { println("Hello") val x: Int = 1 println("World") } Became: <trait> trait Hello extends Object { def <init>(): Hello = { { () } this } <accessor> def x(): Int protected def initial$x(): Int = { println("Hello") 1 } } Notice that the initialization statements after the last getter were missing, this is now fixed: <trait> trait Hello extends Object { def <init>(): Hello = { { println("World") () } this } <accessor> def x(): Int protected def initial$x(): Int = { println("Hello") 1 } }
Diffstat (limited to 'tests/run/traitInit.scala')
-rw-r--r--tests/run/traitInit.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/run/traitInit.scala b/tests/run/traitInit.scala
new file mode 100644
index 000000000..664fe4ce0
--- /dev/null
+++ b/tests/run/traitInit.scala
@@ -0,0 +1,13 @@
+trait Hello {
+ println("Hello")
+ val x: Int = 1
+ println("World")
+}
+
+class A extends Hello
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ new A
+ }
+}