diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-10-06 17:45:38 +1100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-10-07 09:48:40 +1100 |
commit | 55c0581b476381fe66ff0df2ada44560f6511648 (patch) | |
tree | 069e3a658ebf669bd71d55c2f1d537538b1d400d /src | |
parent | ada6b6b67a0ee3fd4e8251d22abce1cdd6cbb931 (diff) | |
download | scala-55c0581b476381fe66ff0df2ada44560f6511648.tar.gz scala-55c0581b476381fe66ff0df2ada44560f6511648.tar.bz2 scala-55c0581b476381fe66ff0df2ada44560f6511648.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/AccessorSynthesis.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/AccessorSynthesis.scala b/src/compiler/scala/tools/nsc/transform/AccessorSynthesis.scala index 120ee5c26e..f1ac2287e2 100644 --- a/src/compiler/scala/tools/nsc/transform/AccessorSynthesis.scala +++ b/src/compiler/scala/tools/nsc/transform/AccessorSynthesis.scala @@ -380,7 +380,7 @@ trait AccessorSynthesis extends Transform with ast.TreeDSL { case tree: RefTree if tree.symbol != NoSymbol => val sym = tree.symbol // println(s"$sym in ${sym.owner} from $currentOwner ($tree)") - if ((sym.hasAccessorFlag || (sym.isTerm && !sym.isMethod)) && sym.isPrivate && !sym.isLazy // non-lazy private field or its accessor + if ((sym.hasAccessorFlag || (sym.isTerm && !sym.isMethod)) && sym.isPrivate && !sym.isLazy && !sym.isModule // non-lazy private field or its accessor && !definitions.isPrimitiveValueClass(sym.tpe.resultType.typeSymbol) // primitives don't hang on to significant amounts of heap && sym.owner == currentOwner.enclClass && !(currentOwner.isGetter && currentOwner.accessed == sym)) { |