Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Two fixes for the worksheet instrumenter

(1) Handle empty worksheets
(2) Handle for expressions

Review by @dragos
(cherry picked from commit 20dc9cd7848863097b07d1cb84ae3f729f7e94da)
  • Loading branch information...
commit 32cb44f9136a03e762baba420c0be2f4c27f4354 1 parent e03a5b7
odersky odersky authored dragos committed
9 src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
View
@@ -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()) {
8 src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala
View
@@ -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 _ =>
}
Please sign in to comment.
Something went wrong with that request. Please try again.