diff options
Diffstat (limited to 'src')
5 files changed, 22 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index d0d66afb57..c7d4f84b45 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -61,8 +61,11 @@ trait CompilationUnits { self: Global => def incompleteInputError(pos: Position, msg:String) = if (inIDE || !(errorPositions contains pos)) { + val hadErrors = !errorPositions.isEmpty + if (!hadErrors) + reporter.incompleteInputError((pos), msg) + else reporter.error((pos), msg) if (!inIDE) errorPositions += pos - reporter.incompleteInputError((pos), msg) } override def toString() = source.toString() diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index b958024b9e..7805fa32da 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -350,24 +350,19 @@ class Interpreter(val settings: Settings, out: PrintWriter) { var justNeedsMore = false reporter.withIncompleteHandler((pos,msg) => {justNeedsMore = true}) { // simple parse: just parse it, nothing else - def simpleParse(code: String): List[Tree] = { - //Console.println("CODE<<" + code + ">>") + def simpleParse(code: String): (List[Tree]) = { + reporter.reset val unit = new CompilationUnit( new BatchSourceFile("<console>", code.toCharArray())) val scanner = new compiler.syntaxAnalyzer.UnitParser(unit); val xxx = scanner.templateStatSeq; - xxx._2 + (xxx._2) } - - // parse the main code along with the imports - reporter.reset - - val trees= simpleParse(line) - - if (justNeedsMore) + val (trees) = simpleParse(line) + if (justNeedsMore) { None - else if (reporter.hasErrors) + } else if (reporter.hasErrors) Some(Nil) // the result did not parse, so stop else Some(trees) @@ -442,7 +437,8 @@ class Interpreter(val settings: Settings, out: PrintWriter) { // parse val trees = parse(line) match { case None => return IR.Incomplete - case Some(Nil) => return IR.Error // parse error or empty input + case (Some(Nil)) => return IR.Error // parse error or empty input + case _ if reporter.hasErrors => return IR.Error case Some(trees) => trees } diff --git a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala index 7ec8b688e7..b2732df204 100644 --- a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala @@ -16,6 +16,11 @@ import nsc.Settings abstract class AbstractReporter extends Reporter { private val positions = new HashSet[Position]() + override def reset = { + super.reset + positions.clear + } + val settings: Settings def display(pos: Position, msg: String, severity: Severity): Unit diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala index 6eb4401c49..3b1f42b86d 100644 --- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala @@ -46,9 +46,11 @@ abstract class Reporter { def error(pos: Position, msg: String ): Unit = info0(pos, msg, ERROR, false) /** An error that could possibly be fixed if the unit were longer. - * This is used, for example, when the interpreter tries + * This is used only when the interpreter tries * to distinguish fatal errors from those that are due to * needing more lines of input from the user. + * + * Should be re-factored into a subclass. */ var incompleteInputError: (Position, String) => Unit = error diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index de832671f8..9c30f08d0b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -160,8 +160,6 @@ trait Namers { self: Analyzer => def enterClassSymbol(tree : ClassDef): Symbol = { var c: Symbol = context.scope.lookup(tree.name); - // Never take the first path in the IDE because we could be completing c.owner's type! - // the other path will handle symbol re-use well enough. if (!inIDE && c.isType && context.scope == c.owner.info.decls && !currentRun.compiles(c)) { updatePosFlags(c, tree.pos, tree.mods.flags) setPrivateWithin(tree, c, tree.mods) @@ -196,8 +194,8 @@ trait Namers { self: Analyzer => updatePosFlags(m, tree.pos, tree.mods.flags|MODULE|FINAL) setPrivateWithin(tree, m, tree.mods) } else { - if (m.isTerm && !m.isPackage && currentRun.compiles(m) && (context.scope == m.owner.info.decls)) - context.scope.unlink(m) + //if (m.isTerm && !m.isPackage && currentRun.compiles(m) && (context.scope == m.owner.info.decls)) + // context.scope.unlink(m) m = context.owner.newModule(tree.pos, tree.name) m.setFlag(tree.mods.flags) |