summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-06-21 00:26:39 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-06-21 00:26:39 -0700
commit320a32b0b5902781b9fb13ad83083574a36f3e46 (patch)
tree3155d95602e4d4012f3aaab3abd931bb68b293f0 /test/files/neg
parent6aea0ae85f72594798ec6c96e30cc1aef48c3a99 (diff)
parent6aa5762fa0333625ec93378e2147649a8bafde34 (diff)
downloadscala-320a32b0b5902781b9fb13ad83083574a36f3e46.tar.gz
scala-320a32b0b5902781b9fb13ad83083574a36f3e46.tar.bz2
scala-320a32b0b5902781b9fb13ad83083574a36f3e46.zip
Merge pull request #735 from retronym/ticket/4842-2
SI-4842 Forbid access to in-construction this in self-constructor args
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/t4842a.check4
-rw-r--r--test/files/neg/t4842a.scala3
-rw-r--r--test/files/neg/t4842b.check4
-rw-r--r--test/files/neg/t4842b.scala3
4 files changed, 14 insertions, 0 deletions
diff --git a/test/files/neg/t4842a.check b/test/files/neg/t4842a.check
new file mode 100644
index 0000000000..39d77bfc48
--- /dev/null
+++ b/test/files/neg/t4842a.check
@@ -0,0 +1,4 @@
+t4842a.scala:2: error: self constructor arguments cannot reference unconstructed `this`
+ def this(x: Int) = this(new { println(Foo.this)}) // error
+ ^
+one error found
diff --git a/test/files/neg/t4842a.scala b/test/files/neg/t4842a.scala
new file mode 100644
index 0000000000..78360effb4
--- /dev/null
+++ b/test/files/neg/t4842a.scala
@@ -0,0 +1,3 @@
+class Foo (x: AnyRef) {
+ def this(x: Int) = this(new { println(Foo.this)}) // error
+}
diff --git a/test/files/neg/t4842b.check b/test/files/neg/t4842b.check
new file mode 100644
index 0000000000..c7ccd5e059
--- /dev/null
+++ b/test/files/neg/t4842b.check
@@ -0,0 +1,4 @@
+t4842b.scala:2: error: self constructor arguments cannot reference unconstructed `this`
+ def this() = { this(???)(new { println(TypeArg.this.x) } ); println("next") } // error
+ ^
+one error found
diff --git a/test/files/neg/t4842b.scala b/test/files/neg/t4842b.scala
new file mode 100644
index 0000000000..a7996cc061
--- /dev/null
+++ b/test/files/neg/t4842b.scala
@@ -0,0 +1,3 @@
+class TypeArg[X](val x: X)(a: AnyRef) {
+ def this() = { this(???)(new { println(TypeArg.this.x) } ); println("next") } // error
+}