diff options
author | Martin Odersky <odersky@gmail.com> | 2014-12-14 15:08:08 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-12-14 15:08:15 +0100 |
commit | 8a2cbf411888083e810c765bf02242e224e31885 (patch) | |
tree | 87678c8254fda3b1072beea3ea79ffdea7f0108d /src/dotty/tools/dotc/core | |
parent | e7a4197cfb7b622893fa0dc99f42824522d89ca1 (diff) | |
download | dotty-8a2cbf411888083e810c765bf02242e224e31885.tar.gz dotty-8a2cbf411888083e810c765bf02242e224e31885.tar.bz2 dotty-8a2cbf411888083e810c765bf02242e224e31885.zip |
Make sure the period of a context always contains a single phase
Multi-phase periods mean that ctx.phaseId is no longer valid, which means
a lot of invariants break.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Phases.scala | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index 6824cc36c..805b7660c 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -77,7 +77,10 @@ object Contexts { /** The current context */ private[this] var _period: Period = _ - protected def period_=(period: Period) = _period = period + protected def period_=(period: Period) = { + assert(period.firstPhaseId == period.lastPhaseId, period) + _period = period + } def period: Period = _period /** The scope nesting level */ @@ -193,7 +196,7 @@ object Contexts { /** This context at given phase. * This method will always return a phase period equal to phaseId, thus will never return squashed phases */ - final def withPhase(phaseId: PhaseId): Context = { + final def withPhase(phaseId: PhaseId): Context = if (this.phaseId == phaseId) this else if (phasedCtx.phaseId == phaseId) phasedCtx else if (phasedCtxs != null && phasedCtxs(phaseId) != null) phasedCtxs(phaseId) @@ -206,7 +209,6 @@ object Contexts { } ctx1 } - } final def withPhase(phase: Phase): Context = withPhase(phase.id) diff --git a/src/dotty/tools/dotc/core/Phases.scala b/src/dotty/tools/dotc/core/Phases.scala index ffe2ddbea..c1bc243a0 100644 --- a/src/dotty/tools/dotc/core/Phases.scala +++ b/src/dotty/tools/dotc/core/Phases.scala @@ -194,7 +194,7 @@ object Phases { def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = units.map { unit => - val unitCtx = ctx.fresh.setPhase(this).setCompilationUnit(unit) + val unitCtx = ctx.fresh.setPhase(this.start).setCompilationUnit(unit) run(unitCtx) unitCtx.compilationUnit } |