summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/Main.scala1
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala6
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Analyzer.scala2
-rw-r--r--test/files/positions/Unsupported1.scala3
5 files changed, 11 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala
index 91129d5fb8..253eebfd0d 100644
--- a/src/compiler/scala/tools/nsc/Main.scala
+++ b/src/compiler/scala/tools/nsc/Main.scala
@@ -50,6 +50,7 @@ object Main extends AnyRef with EvalLoop {
reporter.info(null, versionMsg, true)
else if (command.settings.Yidedebug.value) {
command.settings.Xprintpos.value = true
+ command.settings.Yrangepos.value = true
val compiler = new interactive.Global(command.settings, reporter)
import compiler.{ reporter => _, _ }
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 8f94c64a4e..c2cb2128ee 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -549,7 +549,11 @@ self =>
val opinfo = opstack.head
opstack = opstack.tail
val opPos = r2p(opinfo.offset, opinfo.offset, opinfo.offset+opinfo.operator.length)
- top = atPos(opinfo.operand.pos.startOrPoint, opinfo.offset) {
+ val lPos = opinfo.operand.pos
+ val start = if (lPos.isDefined) lPos.startOrPoint else opPos.startOrPoint
+ val rPos = top.pos
+ val end = if (rPos.isDefined) rPos.endOrPoint else opPos.endOrPoint
+ top = atPos(start, opinfo.offset, end) {
makeBinop(isExpr, opinfo.operand, opinfo.operator, top, opPos)
}
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala b/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala
index b3673f0b82..ab848b6b48 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala
@@ -25,7 +25,7 @@ abstract class SyntaxAnalyzer extends SubComponent with Parsers with MarkupParse
if (unit.source.file.name.endsWith(".java")) new JavaUnitParser(unit).parse()
else if (!global.reporter.incompleteHandled) new UnitParser(unit).smartParse()
else new UnitParser(unit).parse()
- if (global.settings.Yrangepos.value) global.validatePositions(unit.body)
+ if (global.settings.Yrangepos.value && !global.reporter.hasErrors) global.validatePositions(unit.body)
}
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala
index acef0154b2..ef3b7afa95 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala
@@ -55,7 +55,7 @@ trait Analyzer extends AnyRef
def apply(unit: CompilationUnit) {
try {
unit.body = newTyper(rootContext(unit)).typed(unit.body)
- if (global.settings.Yrangepos.value) global.validatePositions(unit.body)
+ if (global.settings.Yrangepos.value && !global.reporter.hasErrors) global.validatePositions(unit.body)
for (workItem <- unit.toCheck) workItem()
} finally {
unit.toCheck.clear()
diff --git a/test/files/positions/Unsupported1.scala b/test/files/positions/Unsupported1.scala
new file mode 100644
index 0000000000..1dca4ad6bb
--- /dev/null
+++ b/test/files/positions/Unsupported1.scala
@@ -0,0 +1,3 @@
+object Unsupported1 {
+ 1 match { case <object>rest }</object> => rest }
+}