diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 9 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala | 8 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 17bea7f796..e79c92e162 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1366,7 +1366,8 @@ self => } parseDo case FOR => - def parseFor = atPos(in.skipToken()) { + val start = in.skipToken() + def parseFor = atPos(start) { val enums = if (in.token == LBRACE) inBracesOrNil(enumerators()) else inParensOrNil(enumerators()) @@ -1378,7 +1379,11 @@ self => makeFor(enums, expr()) } } - parseFor + def adjustStart(tree: Tree) = + if (tree.pos.isRange && start < tree.pos.start) + tree setPos tree.pos.withStart(start) + else tree + adjustStart(parseFor) case RETURN => def parseReturn = atPos(in.skipToken()) { diff --git a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala index efc393c812..2aed99657e 100644 --- a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala +++ b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala @@ -113,9 +113,11 @@ trait ScratchPadMaker { self: Global => val topLevel = objectName.isEmpty if (topLevel) objectName = tree.symbol.fullName body foreach traverseStat - applyPendingPatches(skipped) - if (topLevel) - patches += Patch(skipped, epilogue) + if (skipped != 0) { // don't issue prologue and epilogue if there are no instrumented statements + applyPendingPatches(skipped) + if (topLevel) + patches += Patch(skipped, epilogue) + } case _ => } |