Skip to content

Commit

Permalink
Two fixes for the worksheet instrumenter
Browse files Browse the repository at this point in the history
(1) Handle empty worksheets
(2) Handle for expressions

Review by @dragos
(cherry picked from commit 20dc9cd7848863097b07d1cb84ae3f729f7e94da)
  • Loading branch information
odersky authored and dragos committed Aug 29, 2012
1 parent e03a5b7 commit 32cb44f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 _ =>
}

Expand Down

0 comments on commit 32cb44f

Please sign in to comment.