Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed instrumentation code so that it can deal with:

1. leading imports: object sheet { import math; … }
2. trailing objects: object sheet { … } object other { … }

Review by @dragos
(cherry picked from commit 092eac7)
  • Loading branch information...
commit f98198e8d7cef462f98c2658c4344eba500029d5 1 parent dd423e3
@odersky odersky authored dragos committed
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala
View
13 src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala
@@ -35,7 +35,7 @@ trait ScratchPadMaker { self: Global =>
private def literal(str: String) = "\"\"\""+str+"\"\"\""
- private val prologue = "import scala.runtime.WorksheetSupport._; def main(args: Array[String])=$execute{"
+ private val prologue = ";import scala.runtime.WorksheetSupport._; def main(args: Array[String])=$execute{"
private val epilogue = "}"
@@ -117,12 +117,13 @@ trait ScratchPadMaker { self: Global =>
super.traverse(tree)
case ModuleDef(_, name, Template(_, _, body)) =>
val topLevel = objectName.isEmpty
- if (topLevel) objectName = tree.symbol.fullName
- body foreach traverseStat
- if (skipped != 0) { // don't issue prologue and epilogue if there are no instrumented statements
- applyPendingPatches(skipped)
- if (topLevel)
+ if (topLevel) {
+ objectName = tree.symbol.fullName
+ body foreach traverseStat
+ if (skipped != 0) { // don't issue prologue and epilogue if there are no instrumented statements
+ applyPendingPatches(skipped)
patches += Patch(skipped, epilogue)
+ }
}
case _ =>
}
Please sign in to comment.
Something went wrong with that request. Please try again.