summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Global.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 40d8bd5c82..2e2f9c1ad7 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -661,8 +661,21 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
/** To be initialized from firstPhase. */
private var terminalPhase: Phase = NoPhase
- /** Whether compilation should stop at or skip the phase with given name. */
- protected def stopPhase(name: String) = settings.stop contains name
+ // Calculate where to stop based on settings -Ystop-before or -Ystop-after.
+ // Slightly complicated logic due to wanting -Ystop-before:parser to fail rather
+ // than mysteriously running to completion.
+ private lazy val stopPhaseSetting = {
+ val result = phaseDescriptors sliding 2 collectFirst {
+ case xs if xs exists (settings.stopBefore contains _.phaseName) => if (settings.stopBefore contains xs.head.phaseName) xs.head else xs.last
+ case xs if settings.stopAfter contains xs.head.phaseName => xs.last
+ }
+ if (result exists (_.phaseName == "parser"))
+ globalError("Cannot stop before parser phase.")
+
+ result
+ }
+ // The phase to stop BEFORE running.
+ protected def stopPhase(name: String) = stopPhaseSetting exists (_.phaseName == name)
protected def skipPhase(name: String) = settings.skip contains name
/** As definitions.init requires phase != NoPhase, and calling phaseDescriptors.head