summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2012-09-25 13:03:53 +0200
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2012-09-25 13:03:53 +0200
commitbb48b7a4528335770c7c72341f58f326c11f6284 (patch)
tree23f2e7113b8de7508eadb86884aeb4e228cb507a /src/compiler
parentdb8dea0055739ec39c8765565c5f479ab360acf9 (diff)
downloadscala-bb48b7a4528335770c7c72341f58f326c11f6284.tar.gz
scala-bb48b7a4528335770c7c72341f58f326c11f6284.tar.bz2
scala-bb48b7a4528335770c7c72341f58f326c11f6284.zip
Revert "SI-6412 alleviates leaks in toolboxes"
This reverts commit b403c1d7524ccdfc3455b5bc5d5363fdd9c82bec.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala4
-rw-r--r--src/compiler/scala/tools/reflect/ToolBoxFactory.scala21
2 files changed, 4 insertions, 21 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 0fbd930ad7..58fcee4b30 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -1079,12 +1079,12 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
* of what file was being compiled when it broke. Since I really
* really want to know, this hack.
*/
- protected var lastSeenSourceFile: SourceFile = NoSourceFile
+ private var lastSeenSourceFile: SourceFile = NoSourceFile
/** Let's share a lot more about why we crash all over the place.
* People will be very grateful.
*/
- protected var lastSeenContext: analyzer.Context = null
+ private var lastSeenContext: analyzer.Context = null
/** The currently active run
*/
diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
index 790c78cbf5..f985eedf99 100644
--- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
+++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
@@ -46,23 +46,6 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
newTermName("__wrapper$" + wrapCount + "$" + java.util.UUID.randomUUID.toString.replace("-", ""))
}
- // should be called after every use of ToolBoxGlobal in order to prevent leaks
- // there's the `withCleanupCaches` method defined below, which provides a convenient interface for that
- def cleanupCaches(): Unit = {
- lub(List(IntTpe, IntTpe)) // indirectly clears lubResults and glbResults
- // I didn't want to turn those caches from private to protected
- // in order not to screw up the performance
- perRunCaches.clearAll()
- undoLog.clear()
- analyzer.lastTreeToTyper = EmptyTree
- lastSeenSourceFile = NoSourceFile
- lastSeenContext = null
- }
-
- def withCleanupCaches[T](body: => T): T =
- try body
- finally cleanupCaches()
-
def verify(expr: Tree): Unit = {
// Previously toolboxes used to typecheck their inputs before compiling.
// Actually, the initial demo by Martin first typechecked the reified tree,
@@ -354,7 +337,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
lazy val importer = compiler.mkImporter(u)
lazy val exporter = importer.reverse
- def typeCheck(tree: u.Tree, expectedType: u.Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree = compiler.withCleanupCaches {
+ def typeCheck(tree: u.Tree, expectedType: u.Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree = {
if (compiler.settings.verbose.value) println("importing "+tree+", expectedType = "+expectedType)
var ctree: compiler.Tree = importer.importTree(tree)
var cexpectedType: compiler.Type = importer.importType(expectedType)
@@ -374,7 +357,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
inferImplicit(tree, viewTpe, isView = true, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos)
}
- private def inferImplicit(tree: u.Tree, pt: u.Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: u.Position): u.Tree = compiler.withCleanupCaches {
+ private def inferImplicit(tree: u.Tree, pt: u.Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: u.Position): u.Tree = {
if (compiler.settings.verbose.value) println("importing "+pt, ", tree = "+tree+", pos = "+pos)
var ctree: compiler.Tree = importer.importTree(tree)
var cpt: compiler.Type = importer.importType(pt)