summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2009-03-30 14:50:49 +0000
committerIulian Dragos <jaguarul@gmail.com>2009-03-30 14:50:49 +0000
commit845c4fcd316ea0ec0b9ad38cad80d77a93607342 (patch)
treebd00d2dfe685d4afea75ce84d02641bf124fa5ef /test/files/run
parentfaa34dab7d0528cdaf9b0e0e5a47a39dc46adc87 (diff)
downloadscala-845c4fcd316ea0ec0b9ad38cad80d77a93607342.tar.gz
scala-845c4fcd316ea0ec0b9ad38cad80d77a93607342.tar.bz2
scala-845c4fcd316ea0ec0b9ad38cad80d77a93607342.zip
Fixed nested lazy values (#1589).
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/lazy-locals.check5
-rw-r--r--test/files/run/lazy-locals.scala24
2 files changed, 29 insertions, 0 deletions
diff --git a/test/files/run/lazy-locals.check b/test/files/run/lazy-locals.check
index 63beca0717..7d14da243b 100644
--- a/test/files/run/lazy-locals.check
+++ b/test/files/run/lazy-locals.check
@@ -82,3 +82,8 @@ forced lazy val t at n = 5
First 5 elements of ones: List(1, 1, 1, 1, 1)
I am initialized when the constructor is run
false
+forcing x
+forcing y
+42
+15
+42
diff --git a/test/files/run/lazy-locals.scala b/test/files/run/lazy-locals.scala
index 5279901795..be738a0f70 100644
--- a/test/files/run/lazy-locals.scala
+++ b/test/files/run/lazy-locals.scala
@@ -161,6 +161,28 @@ object Test extends Application {
}
}
+ // see #1589
+ object NestedLazyVals extends Application {
+ lazy val x = {
+ lazy val y = { println("forcing y"); 42; }
+ println("forcing x")
+ y
+ }
+
+ val x1 = 5 + { lazy val y = 10 ; y }
+
+ println(x)
+ println(x1)
+ }
+
+ trait TNestedLazyVals {
+ lazy val x = { lazy val y = 42; y }
+ }
+
+ object ONestedLazyVals extends Application with TNestedLazyVals {
+ println(x)
+ }
+
println(testLazy)
testLazy32
testLazy33
@@ -169,4 +191,6 @@ object Test extends Application {
testRecVal
new CtorBlock
println(testReturnInLazyVal)
+ NestedLazyVals
+ ONestedLazyVals
}