summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/TreeGen.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-01-15 18:00:51 +0000
committerPaul Phillips <paulp@improving.org>2010-01-15 18:00:51 +0000
commit9bd9b9fcc1623ca3b6c98cb7ce12f31581750372 (patch)
treef3a12a4788db0879fa06666caf335dedf5c3357a /src/compiler/scala/tools/nsc/ast/TreeGen.scala
parent3e1241caeca9af5b05922d38bed1b0480e6da56d (diff)
downloadscala-9bd9b9fcc1623ca3b6c98cb7ce12f31581750372.tar.gz
scala-9bd9b9fcc1623ca3b6c98cb7ce12f31581750372.tar.bz2
scala-9bd9b9fcc1623ca3b6c98cb7ce12f31581750372.zip
Fix for #2365.
a soft reference around cached classes so they do not interfere with garbage collection. There is a test case, but it is in pending because I spent longer trying to get it to fail under partest than I did writing the actual patch. If you would like to see the behavior which was corrected, go to test/pending/run/bug2365 and run that script with scalac built before and after this commit. Review by dubochet.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/TreeGen.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index c5a8b93c88..7f2bcf99c5 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -228,6 +228,9 @@ abstract class TreeGen
def mkOr(tree1: Tree, tree2: Tree): Tree =
Apply(Select(tree1, Boolean_or), List(tree2))
+ // wrap the given expression in a SoftReference so it can be gc-ed
+ def mkSoftRef(expr: Tree): Tree = New(TypeTree(SoftReferenceClass.tpe), List(List(expr)))
+
def mkCached(cvar: Symbol, expr: Tree): Tree = {
val cvarRef = if (cvar.owner.isClass) Select(This(cvar.owner), cvar) else Ident(cvar)
Block(