From 55c0581b476381fe66ff0df2ada44560f6511648 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 6 Oct 2016 17:45:38 +1100 Subject: SI-9946 make nullification of lazy val dependencies module aware If a non-transient lazy val is the only user of a private field in a class, the field is nulled out at the end of the lazy initializer. This is tested in the existing test `run/lazy-leaks.scala`. The analysis of which fields could be nulled out was recently moved from `mixin` to the new `fields` phase. This introduced a regression as a it didn't account for the richer pallete of trees and symbols at that juncture. This commit excludes references to private member modules from collection of private fields, thus avoiding a later compiler crash in the backend due to a nonsense tree trying to null out the module symbol. It might make sense to null out the module var, but I've opted to limit the scope of this analysis to paramaccessors and regular fields. --- test/files/run/t9946a.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 test/files/run/t9946a.scala (limited to 'test/files/run/t9946a.scala') diff --git a/test/files/run/t9946a.scala b/test/files/run/t9946a.scala new file mode 100644 index 0000000000..491fb31f7b --- /dev/null +++ b/test/files/run/t9946a.scala @@ -0,0 +1,14 @@ +package p1 { + object O { + private case class N(a: Any) + lazy val x: AnyRef = N + lazy val y: AnyRef = new { assert(N != null) } + } +} + +object Test { + def main(args: Array[String]): Unit = { + p1.O.x + p1.O.y + } +} -- cgit v1.2.3