From 256aca612204f1316e5281af6d10a14300d58ad1 Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Fri, 1 Oct 2010 17:10:27 +0000 Subject: Another attempt for #1591. --- test/files/jvm/serialization.scala | 26 ++++++++++++++++++++++++++ test/files/pos/t1591_pos.scala | 7 +++++++ test/files/pos/t1591b.scala | 13 +++++++++++++ test/files/run/t1591.check | 1 + test/files/run/t1591.scala | 14 ++++++++++++++ 5 files changed, 61 insertions(+) create mode 100644 test/files/pos/t1591_pos.scala create mode 100644 test/files/pos/t1591b.scala create mode 100644 test/files/run/t1591.check create mode 100644 test/files/run/t1591.scala (limited to 'test') diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala index 06086f4038..b8656888c6 100644 --- a/test/files/jvm/serialization.scala +++ b/test/files/jvm/serialization.scala @@ -531,6 +531,31 @@ object Test6 { } } +//############################################################################ +// Nested objects cannot get readresolve automatically because after deserialization +// they would be null (they are treated as lazy vals) +@serializable +class Outer { + + @serializable + object Inner +} + +object Test7 { + val x = new Outer + x.Inner // initialize + try { + val y:Outer = read(write(x)) + if (y.Inner == null) + println("Inner object is null") + } + catch { + case e: Exception => + println("Error in Test7: " + e) + } + +} + //############################################################################ // Test code @@ -542,6 +567,7 @@ object Test { Test4_xml Test5 Test6 + Test7 } } diff --git a/test/files/pos/t1591_pos.scala b/test/files/pos/t1591_pos.scala new file mode 100644 index 0000000000..4f55d7ce19 --- /dev/null +++ b/test/files/pos/t1591_pos.scala @@ -0,0 +1,7 @@ +trait A + +object Test { + lazy val a = new A { + object Zenek + } +} diff --git a/test/files/pos/t1591b.scala b/test/files/pos/t1591b.scala new file mode 100644 index 0000000000..c671ad6472 --- /dev/null +++ b/test/files/pos/t1591b.scala @@ -0,0 +1,13 @@ +import scala.tools.nsc._ + +class SemanticTokens(val compiler: Global) { + import compiler._ + + def build() = ErrorType + + class Process { + def f() = analyzer + // or to crash the compiler instead of a nice message, + // def f() = analyzer underlying _ + } +} diff --git a/test/files/run/t1591.check b/test/files/run/t1591.check new file mode 100644 index 0000000000..48082f72f0 --- /dev/null +++ b/test/files/run/t1591.check @@ -0,0 +1 @@ +12 diff --git a/test/files/run/t1591.scala b/test/files/run/t1591.scala new file mode 100644 index 0000000000..434064a5dd --- /dev/null +++ b/test/files/run/t1591.scala @@ -0,0 +1,14 @@ +abstract class A { + + lazy val lazyBar = bar + + object bar { + val foo = 12 + } + +} + +object Test extends Application { + val a = new A{} + println(a.lazyBar.foo) +} -- cgit v1.2.3