summaryrefslogtreecommitdiff
path: root/test/files/run/bug4680.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-06-10 22:38:17 +0000
committerPaul Phillips <paulp@improving.org>2011-06-10 22:38:17 +0000
commitc8f4316b374d78caaf5ba605cd34e323b78a77de (patch)
treeef5a8e696e7ba9b7e3578ae6be3d9c5845e4372a /test/files/run/bug4680.scala
parent21e90dfb5958bd5a8030a6edf16b38518e2d69e5 (diff)
downloadscala-c8f4316b374d78caaf5ba605cd34e323b78a77de.tar.gz
scala-c8f4316b374d78caaf5ba605cd34e323b78a77de.tar.bz2
scala-c8f4316b374d78caaf5ba605cd34e323b78a77de.zip
A test case demonstrating some of the issues wi...
A test case demonstrating some of the issues with DelayedInit. References #4680. Review by odersky.
Diffstat (limited to 'test/files/run/bug4680.scala')
-rw-r--r--test/files/run/bug4680.scala71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/files/run/bug4680.scala b/test/files/run/bug4680.scala
new file mode 100644
index 0000000000..d5c8d0e7af
--- /dev/null
+++ b/test/files/run/bug4680.scala
@@ -0,0 +1,71 @@
+trait A extends DelayedInit {
+ print("-A ")
+
+ def delayedInit(body: => Unit) = {
+ body
+ postConstructionCode
+ }
+ protected def postConstructionCode: Unit = {
+ print("\nA+ ")
+ }
+}
+trait B extends A {
+ print("-B ")
+ override protected def postConstructionCode: Unit = {
+ super.postConstructionCode
+ print("B+ ")
+ }
+}
+
+trait C extends B {
+ print("-C ")
+ override protected def postConstructionCode: Unit = {
+ super.postConstructionCode
+ print("C+ ")
+ }
+}
+
+class D() extends C {
+ print("-D ")
+ override protected def postConstructionCode: Unit = {
+ super.postConstructionCode
+ print("D+ ")
+ }
+}
+class E() extends D() {
+ println("-E")
+ override protected def postConstructionCode: Unit = {
+ super.postConstructionCode
+ println("E+")
+ }
+}
+
+
+object Test {
+ def p(msg: String) = println("\n\n// " + msg)
+
+ def main(args: Array[String]) {
+ p("new C { }")
+ new C { }
+ p("new C { 5 }")
+ new C { 5 }
+
+ p("new D()")
+ new D()
+ p("new D() { }")
+ new D() { }
+ p("new D() { val x = 5 }")
+ new D() { val x = 5 }
+ p("new { val x = 5 } with D()")
+ new { val x = 5 } with D()
+
+ p("new E() { val x = 5 }")
+ new E() { val x = 5 }
+ p("new { val x = 5 } with E()")
+ new { val x = 5 } with E()
+ p("new { val x = 5 } with E() { }")
+ new { val x = 5 } with E() { }
+ p("new { val x = 5 } with E() { 5 }")
+ new { val x = 5 } with E() { 5 }
+ }
+}