diff options
author | Martin Odersky <odersky@gmail.com> | 2014-03-26 17:02:49 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-03-27 12:42:49 +0100 |
commit | a6419fbd80bb63413de671af331ae35da4fa4e1b (patch) | |
tree | cd82a9535e11f1075c3467d14728f0dc9a08a4cc /src/dotty/tools/dotc/core/Denotations.scala | |
parent | 29c876a40adaae17d4f47cee906243bda9d8e606 (diff) | |
download | dotty-a6419fbd80bb63413de671af331ae35da4fa4e1b.tar.gz dotty-a6419fbd80bb63413de671af331ae35da4fa4e1b.tar.bz2 dotty-a6419fbd80bb63413de671af331ae35da4fa4e1b.zip |
Fix Denotations#current
The logic for dealing with periods in denotation histories did not
correctly take into account the case where the current validity period of
a denotation ends some phases before the next type transformer starts.
And there was an off-by-one error in startPid.
And Types#computeDenot erroneously tried to reload denotations even
the run did not change.
Diffstat (limited to 'src/dotty/tools/dotc/core/Denotations.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Denotations.scala | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index 35f6bd56f..1e3dec255 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -19,6 +19,7 @@ import printing.Printer import io.AbstractFile import config.Config import util.common._ +import collection.mutable.ListBuffer import Decorators.SymbolIteratorDecorator /** Denotations represent the meaning of symbols and named types. @@ -459,7 +460,7 @@ object Denotations { * 2) the union of all validity periods is a contiguous * interval. */ - var nextInRun: SingleDenotation = this + private var nextInRun: SingleDenotation = this /** The version of this SingleDenotation that was valid in the first phase * of this run. @@ -470,6 +471,17 @@ object Denotations { current } + def history: List[SingleDenotation] = { + val b = new ListBuffer[SingleDenotation] + var current = initial + do { + b += (current) + current = current.nextInRun + } + while (current ne initial) + b.toList + } + /** Move validity period of this denotation to a new run. Throw a StaleSymbol error * if denotation is no longer valid. */ @@ -518,27 +530,30 @@ object Denotations { cur = next cur } else { + //println(s"might need new denot for $cur, valid for ${cur.validFor} at $currentPeriod") // not found, cur points to highest existing variant - var startPid = cur.validFor.lastPhaseId + 1 - val nextTranformerId = ctx.nextDenotTransformerId(startPid) - val transformer = ctx.denotTransformers(nextTranformerId) - //println(s"transforming with $transformer") - if (currentPeriod.lastPhaseId > transformer.id) - next = transformer.transform(cur)(ctx.withPhase(startPid)).syncWithParents - if (next eq cur) - startPid = cur.validFor.firstPhaseId + val nextTransformerId = ctx.nextDenotTransformerId(cur.validFor.lastPhaseId) + if (currentPeriod.lastPhaseId <= nextTransformerId) + cur.validFor = Period(currentPeriod.runId, cur.validFor.firstPhaseId, nextTransformerId) else { - next match { - case next: ClassDenotation => next.resetFlag(Frozen) - case _ => + var startPid = nextTransformerId + 1 + val transformer = ctx.denotTransformers(nextTransformerId) + //println(s"transforming $this with $transformer") + next = transformer.transform(cur)(ctx.withPhase(transformer)).syncWithParents + if (next eq cur) + startPid = cur.validFor.firstPhaseId + else { + next match { + case next: ClassDenotation => next.resetFlag(Frozen) + case _ => + } + next.nextInRun = cur.nextInRun + cur.nextInRun = next + cur = next } - next.nextInRun = cur.nextInRun - cur.nextInRun = next - cur = next + cur.validFor = Period(currentPeriod.runId, startPid, transformer.lastPhaseId) + //println(s"new denot: $cur, valid for ${cur.validFor}") } - cur.validFor = Period( - currentPeriod.runId, startPid, transformer.lastPhaseId) - //println(s"new denot: $cur, valid for ${cur.validFor}") cur.current // multiple transformations could be required } } else { @@ -562,7 +577,7 @@ object Denotations { case denot: SymDenotation => s"in ${denot.owner}" case _ => "" } - def msg = s"stale symbol; $this#${symbol.id}$ownerMsg, defined in run ${myValidFor.runId}, is referred to in run ${ctx.period.runId}" + def msg = s"stale symbol; $this#${symbol.id} $ownerMsg, defined in run ${myValidFor.runId}, is referred to in run ${ctx.runId}" throw new StaleSymbol(msg) } |