aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Contexts.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-12-14 15:08:08 +0100
committerMartin Odersky <odersky@gmail.com>2014-12-14 15:08:15 +0100
commit8a2cbf411888083e810c765bf02242e224e31885 (patch)
tree87678c8254fda3b1072beea3ea79ffdea7f0108d /src/dotty/tools/dotc/core/Contexts.scala
parente7a4197cfb7b622893fa0dc99f42824522d89ca1 (diff)
downloaddotty-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/Contexts.scala')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala8
1 files changed, 5 insertions, 3 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)