From 845c4fcd316ea0ec0b9ad38cad80d77a93607342 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Mon, 30 Mar 2009 14:50:49 +0000 Subject: Fixed nested lazy values (#1589). --- test/files/run/lazy-locals.check | 5 +++++ test/files/run/lazy-locals.scala | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'test/files/run') 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 } -- cgit v1.2.3