summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@epfl.ch>2010-10-20 13:26:02 +0000
committerHubert Plociniczak <hubert.plociniczak@epfl.ch>2010-10-20 13:26:02 +0000
commitde3e8492e61e02777520e8876e9e1bccb4b0f065 (patch)
treec125c022ff9c7e5249a3c31cfac1aa8997493a52 /test
parent7a4b4c7a97b0b9417a82bc03ecac31ffe16cf40c (diff)
downloadscala-de3e8492e61e02777520e8876e9e1bccb4b0f065.tar.gz
scala-de3e8492e61e02777520e8876e9e1bccb4b0f065.tar.bz2
scala-de3e8492e61e02777520e8876e9e1bccb4b0f065.zip
Closes #2910.
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t2910.check16
-rw-r--r--test/files/neg/t2910.scala38
-rw-r--r--test/files/pos/t2910.scala33
3 files changed, 87 insertions, 0 deletions
diff --git a/test/files/neg/t2910.check b/test/files/neg/t2910.check
new file mode 100644
index 0000000000..afff73ec08
--- /dev/null
+++ b/test/files/neg/t2910.check
@@ -0,0 +1,16 @@
+t2910.scala:3: error: forward reference extends over definition of value ret
+ val ret = l.map({ case MyMatch(id) => id })
+ ^
+t2910.scala:9: error: forward reference extends over definition of value z
+ println(s.length)
+ ^
+t2910.scala:16: error: forward reference extends over definition of value z
+ x
+ ^
+t2910.scala:30: error: forward reference extends over definition of value x
+ lazy val f: Int = x
+ ^
+t2910.scala:34: error: forward reference extends over definition of variable x
+ lazy val f: Int = g
+ ^
+5 errors found \ No newline at end of file
diff --git a/test/files/neg/t2910.scala b/test/files/neg/t2910.scala
new file mode 100644
index 0000000000..1c7ba54971
--- /dev/null
+++ b/test/files/neg/t2910.scala
@@ -0,0 +1,38 @@
+object Junk {
+ def f(l: List[String]): List[String] = {
+ val ret = l.map({ case MyMatch(id) => id })
+ val MyMatch = "(\\d+)".r
+ ret
+ }
+
+ def test2 {
+ println(s.length)
+ val z = 0
+ lazy val s = "abc"
+ }
+
+ def test4 {
+ lazy val x = {
+ x
+ val z = 0
+ lazy val x = 12
+ z
+ }
+ }
+}
+
+// updated forwards.scala for lazy vals
+object Test {
+ lazy val f: Int = x
+ val x: Int = f
+
+ {
+ lazy val f: Int = x
+ val x: Int = f
+ }
+ {
+ lazy val f: Int = g
+ var x: Int = f
+ lazy val g: Int = x
+ }
+}
diff --git a/test/files/pos/t2910.scala b/test/files/pos/t2910.scala
new file mode 100644
index 0000000000..d4d92fa765
--- /dev/null
+++ b/test/files/pos/t2910.scala
@@ -0,0 +1,33 @@
+object Test {
+ def test1 {
+ C
+ object C
+ }
+
+ def test2 {
+ println(s.length)
+ lazy val s = "abc"
+ }
+
+ def test3 {
+ lazy val lazyBar = bar
+ object bar {
+ val foo = 12
+ }
+ lazy val lazyBar2 = bar
+ }
+
+ def test4 {
+ lazy val x = {
+ x
+ lazy val x = 12
+ 0
+ }
+ }
+
+ def test5 {
+ lazy val f: Int = g
+ Console.println("foo")
+ lazy val g: Int = f
+ }
+} \ No newline at end of file