aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-17 10:01:48 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-11 08:24:35 +0200
commit8918bd94813c254dcd0e19d0c16726bb5450e27a (patch)
tree83adc4b412667dcd6a6869cb5ab8e688a872208e /src/dotty/tools
parent70087826a64e027b72fc8235172bf2eee04b9d20 (diff)
downloaddotty-8918bd94813c254dcd0e19d0c16726bb5450e27a.tar.gz
dotty-8918bd94813c254dcd0e19d0c16726bb5450e27a.tar.bz2
dotty-8918bd94813c254dcd0e19d0c16726bb5450e27a.zip
Make enteredAfter, installAfter more forgiving as to when they are called.
Instead of requiring to be called a given phase, change the context if that is not the case.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala36
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala18
2 files changed, 26 insertions, 28 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index 9970c5948..09b67d08a 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -603,26 +603,26 @@ object Denotations {
*/
protected def installAfter(phase: DenotTransformer)(implicit ctx: Context): Unit = {
val targetId = phase.next.id
- assert(ctx.phaseId == targetId,
- s"denotation update for $this called in phase ${ctx.phase}, expected was ${phase.next}")
- val current = symbol.current
- // println(s"installing $this after $phase/${phase.id}, valid = ${current.validFor}")
- // printPeriods(current)
- this.nextInRun = current.nextInRun
- this.validFor = Period(ctx.runId, targetId, current.validFor.lastPhaseId)
- if (current.validFor.firstPhaseId == targetId) {
- // replace current with this denotation
- var prev = current
- while (prev.nextInRun ne current) prev = prev.nextInRun
- prev.nextInRun = this
- current.validFor = Nowhere
- }
+ if (ctx.phaseId != targetId) installAfter(phase)(ctx.withPhase(phase.next))
else {
- // insert this denotation after current
- current.validFor = Period(ctx.runId, current.validFor.firstPhaseId, targetId - 1)
- current.nextInRun = this
- }
+ val current = symbol.current
+ // println(s"installing $this after $phase/${phase.id}, valid = ${current.validFor}")
+ // printPeriods(current)
+ this.nextInRun = current.nextInRun
+ this.validFor = Period(ctx.runId, targetId, current.validFor.lastPhaseId)
+ if (current.validFor.firstPhaseId == targetId) {
+ // replace current with this denotation
+ var prev = current
+ while (prev.nextInRun ne current) prev = prev.nextInRun
+ prev.nextInRun = this
+ current.validFor = Nowhere
+ } else {
+ // insert this denotation after current
+ current.validFor = Period(ctx.runId, current.validFor.firstPhaseId, targetId - 1)
+ current.nextInRun = this
+ }
// printPeriods(this)
+ }
}
def staleSymbolError(implicit ctx: Context) = {
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 073c9112d..1316e7872 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -1425,19 +1425,17 @@ object SymDenotations {
/** If this class has the same `decls` scope reference in `phase` and
* `phase.next`, install a new denotation with a cloned scope in `phase.next`.
- * @pre Can only be called in `phase.next`.
*/
- def ensureFreshScopeAfter(phase: DenotTransformer)(implicit ctx: Context): Unit = {
- assert(ctx.phaseId == phase.next.id)
- val prevCtx = ctx.withPhase(phase)
- val ClassInfo(pre, _, ps, decls, selfInfo) = classInfo
- if (classInfo(prevCtx).decls eq decls) {
- copySymDenotation(
- info = ClassInfo(pre, classSymbol, ps, decls.cloneScope, selfInfo),
- initFlags = this.flags &~ Frozen).installAfter(phase)
+ def ensureFreshScopeAfter(phase: DenotTransformer)(implicit ctx: Context): Unit =
+ if (ctx.phaseId != phase.next.id) ensureFreshScopeAfter(phase)(ctx.withPhase(phase.next))
+ else {
+ val prevCtx = ctx.withPhase(phase)
+ val ClassInfo(pre, _, ps, decls, selfInfo) = classInfo
+ if (classInfo(prevCtx).decls eq decls)
+ copySymDenotation(info = ClassInfo(pre, classSymbol, ps, decls.cloneScope, selfInfo))
+ .installAfter(phase)
}
}
- }
private case class Uncachable(tp: Type) extends UncachedGroundType