diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/interactive/Global.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 13 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 1 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 8af350c8b7..99619e3a2f 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -39,6 +39,7 @@ self => else NullLogger import log.logreplay + debugLog("logger: " + log.getClass + " writing to " + (new java.io.File(logName)).getAbsolutePath) /** Print msg only when debugIDE is true. */ @inline final def debugLog(msg: => String) = diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index ef45834ab7..e3fb82385b 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -8,6 +8,7 @@ package symtab import scala.collection.{ mutable, immutable } import scala.collection.mutable.ListBuffer +import scala.ref.WeakReference import ast.TreeGen import util.{ Position, NoPosition } import util.Statistics._ @@ -150,7 +151,7 @@ trait Types extends reflect.generic.Types { self: SymbolTable => * It makes use of the fact that these two operations depend only on the parents, * not on the refinement. */ - val intersectionWitness = new mutable.WeakHashMap[List[Type], Type] + val intersectionWitness = new mutable.WeakHashMap[List[Type], WeakReference[Type]] private object gen extends { val global : Types.this.type = Types.this @@ -1341,12 +1342,12 @@ trait Types extends reflect.generic.Types { self: SymbolTable => baseClassesCache } - def memo[A](op1: => A)(op2: Type => A) = intersectionWitness get parents match { - case Some(w) => - if (w eq this) op1 else op2(w) - case none => - intersectionWitness(parents) = this + def memo[A](op1: => A)(op2: Type => A) = { + (for (ref <- intersectionWitness.get(parents); w <- ref.get) + yield if (w eq this) op1 else op2(w)) getOrElse { + intersectionWitness(parents) = new WeakReference(this) op1 + } } override def baseType(sym: Symbol): Type = { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index bcb2767e6f..784531ba1e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -49,6 +49,7 @@ trait Typers extends Modes { resetNamer() resetImplicits() transformed.clear() + //println("%,d entries in intersectionWitness".format(intersectionWitness.size)) } object UnTyper extends Traverser { |