summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-05-11 00:11:45 +0200
committerJason Zaugg <jzaugg@gmail.com>2012-05-11 07:31:20 +0200
commitd35e74eb6bc13f1f354029c9439cef35aecd972b (patch)
tree14f4e936bd3bf381f97370aa5233b7c9f871fdf4 /test
parentdf10f921158ea13ce8fb53c8e15ec290ace69d83 (diff)
downloadscala-d35e74eb6bc13f1f354029c9439cef35aecd972b.tar.gz
scala-d35e74eb6bc13f1f354029c9439cef35aecd972b.tar.bz2
scala-d35e74eb6bc13f1f354029c9439cef35aecd972b.zip
Forbid forward refs from self constructor invocations.
Prevents the wheels falling off during later compiler phases, or, worse, during bytecode verification. Closes SI-4098.
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t4098.check13
-rw-r--r--test/files/neg/t4098.scala22
2 files changed, 35 insertions, 0 deletions
diff --git a/test/files/neg/t4098.check b/test/files/neg/t4098.check
new file mode 100644
index 0000000000..7d69cf151c
--- /dev/null
+++ b/test/files/neg/t4098.check
@@ -0,0 +1,13 @@
+t4098.scala:3: error: forward reference not allowed from self constructor invocation
+ this(b)
+ ^
+t4098.scala:8: error: forward reference not allowed from self constructor invocation
+ this(b)
+ ^
+t4098.scala:13: error: forward reference not allowed from self constructor invocation
+ this(b)
+ ^
+t4098.scala:18: error: forward reference not allowed from self constructor invocation
+ this(b)
+ ^
+four errors found
diff --git a/test/files/neg/t4098.scala b/test/files/neg/t4098.scala
new file mode 100644
index 0000000000..744d6191b5
--- /dev/null
+++ b/test/files/neg/t4098.scala
@@ -0,0 +1,22 @@
+class A(a: Any) {
+ def this() = {
+ this(b)
+ def b = new {}
+ }
+
+ def this(x: Int) = {
+ this(b)
+ lazy val b = new {}
+ }
+
+ def this(x: Int, y: Int) = {
+ this(b)
+ val b = new {}
+ }
+
+ def this(x: Int, y: Int, z: Int) = {
+ this(b)
+ println(".")
+ def b = new {}
+ }
+}