diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-07-01 16:26:46 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-08-19 17:47:11 +0200 |
commit | bdc3ff97e7f869b393de7e4deb53535a93738ad1 (patch) | |
tree | 45b9539c0a51b955be83ef562277c67058317b3e /src | |
parent | 5e0880fe05fb65a8757721be7e5be6a3259c19a8 (diff) | |
download | scala-bdc3ff97e7f869b393de7e4deb53535a93738ad1.tar.gz scala-bdc3ff97e7f869b393de7e4deb53535a93738ad1.tar.bz2 scala-bdc3ff97e7f869b393de7e4deb53535a93738ad1.zip |
Set currentUnit while generating bytecode.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 5bf0d8d9f7..08d2b89ece 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -395,7 +395,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) reporter.cancelled || unit.isJava && this.id > maxJavaPhase } - final def applyPhase(unit: CompilationUnit) { + final def withCurrentUnit(unit: CompilationUnit)(task: => Unit) { if ((unit ne null) && unit.exists) lastSeenSourceFile = unit.source @@ -407,7 +407,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) currentRun.currentUnit = unit if (!cancelled(unit)) { currentRun.informUnitStarting(this, unit) - apply(unit) + task } currentRun.advanceUnit() } finally { @@ -415,6 +415,8 @@ class Global(var currentSettings: Settings, var reporter: Reporter) currentRun.currentUnit = unit0 } } + + final def applyPhase(unit: CompilationUnit) = withCurrentUnit(unit)(apply(unit)) } // phaseName = "parser" diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala index 89866b7ce9..5494a827f4 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala @@ -130,7 +130,7 @@ abstract class GenBCode extends BCodeSyncAndTry { return } else { - try { visit(item) } + try { withCurrentUnit(item.cunit)(visit(item)) } catch { case ex: Throwable => ex.printStackTrace() |