diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/interactive/Global.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala | 22 |
3 files changed, 14 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 0f8e039323..d1091a4b7c 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1124,6 +1124,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable def forJVM = opt.jvm def forMSIL = opt.msil + def forInteractive = false def onlyPresentation = false def createJavadoc = false } diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index da6051acae..f44093dc5e 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -32,6 +32,7 @@ self => if (debugIDE) println(msg) override def onlyPresentation = true + override def forInteractive = true /** A list indicating in which order some units should be typechecked. * All units in firsts are typechecked before any unit not in this list diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 77428f127d..f71d085333 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -147,16 +147,18 @@ abstract class SymbolLoaders { val sourcepaths = classpath.sourcepaths for (classRep <- classpath.classes if doLoad(classRep)) { - if (classRep.binary.isDefined && classRep.source.isDefined) { - val (bin, src) = (classRep.binary.get, classRep.source.get) - val loader = if (needCompile(bin, src)) new SourcefileLoader(src) - else newClassLoader(bin) - enterClassAndModule(root, classRep.name, loader) - } else if (classRep.binary.isDefined) { - enterClassAndModule(root, classRep.name, newClassLoader(classRep.binary.get)) - } else if (classRep.source.isDefined) { - enterClassAndModule(root, classRep.name, new SourcefileLoader(classRep.source.get)) - } + def enterToplevels(src: AbstractFile) { + if (global.forInteractive) + // Parse the source right away in the presentation compiler. + global.currentRun.compileLate(src) + else + enterClassAndModule(root, classRep.name, new SourcefileLoader(src)) + } + ((classRep.binary, classRep.source) : @unchecked) match { + case (Some(bin), Some(src)) if needCompile(bin, src) => enterToplevels(src) + case (None, Some(src)) => enterToplevels(src) + case (Some(bin), _) => enterClassAndModule(root, classRep.name, newClassLoader(bin)) + } } for (pkg <- classpath.packages) { |