diff options
Diffstat (limited to 'src')
3 files changed, 22 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/dependencies/References.scala b/src/compiler/scala/tools/nsc/dependencies/References.scala index 23bfba9e31..716f42116a 100644 --- a/src/compiler/scala/tools/nsc/dependencies/References.scala +++ b/src/compiler/scala/tools/nsc/dependencies/References.scala @@ -14,11 +14,16 @@ abstract class References extends SubComponent with Files { def newPhase(prev: Phase) = new ReferenceAnalysisPhase(prev) /** Top level definitions per source file. */ - val definitions: mutable.Map[AbstractFile, List[Symbol]] = new mutable.HashMap[AbstractFile, List[Symbol]] + val definitions: mutable.Map[AbstractFile, List[Symbol]] = + new mutable.HashMap[AbstractFile, List[Symbol]] { + override def default(f : AbstractFile) = Nil + } /** External references used by source file. */ var references: immutable.Map[AbstractFile, immutable.Set[String]] = - new immutable.HashMap[AbstractFile, immutable.Set[String]] + new immutable.HashMap[AbstractFile, immutable.Set[String]] { + override def default(f : AbstractFile) = immutable.Set() + } class ReferenceAnalysisPhase(prev: Phase) extends StdPhase(prev) { def apply(unit: global.CompilationUnit) { diff --git a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala index 2c2c7b2b2e..7120254c5d 100644 --- a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala @@ -30,8 +30,13 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana phasesSet += dependencyAnalysis phasesSet += referencesAnalysis } + + def newRun() = new Run() } - val compiler = new BuilderGlobal(settings) + + protected def newCompiler(settings: Settings) = new BuilderGlobal(settings) + + val compiler = newCompiler(settings) import compiler.Symbol /** Managed source files. */ @@ -62,7 +67,7 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana */ def update(files: Set[AbstractFile]): Unit = if (!files.isEmpty) { val deps = compiler.dependencyAnalysis.dependencies - val run = new compiler.Run() + val run = compiler.newRun() compiler.inform("compiling " + files) run.compileFiles(files.toList) diff --git a/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala index 9ec69b3af5..b5f0951656 100644 --- a/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala @@ -18,7 +18,13 @@ import io.AbstractFile */ class SimpleBuildManager(val settings: Settings) extends BuildManager { - val compiler: scala.tools.nsc.Global = new scala.tools.nsc.Global(settings) + class BuilderGlobal(settings: Settings) extends scala.tools.nsc.Global(settings) { + def newRun() = new Run() + } + + protected def newCompiler(settings: Settings) = new BuilderGlobal(settings) + + val compiler = newCompiler(settings) /** Managed source files. */ private val sources: mutable.Set[AbstractFile] = new mutable.HashSet[AbstractFile] @@ -40,7 +46,7 @@ class SimpleBuildManager(val settings: Settings) extends BuildManager { */ def update(files: Set[AbstractFile]) { val deps = compiler.dependencyAnalysis.dependencies - val run = new compiler.Run() + val run = compiler.newRun() compiler.inform("compiling " + files) val toCompile = |