From f4e9a881a561e28900becc7deea520b43e57fb31 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 9 Feb 2014 13:35:17 +0100 Subject: WIP: Fixes to bring symbols forward --- src/dotty/tools/dotc/core/Denotations.scala | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/dotty/tools/dotc/core/Denotations.scala') diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index 2ad193970..356e68f72 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -461,6 +461,18 @@ object Denotations { current } + protected def bringForward()(implicit ctx: Context): SingleDenotation = this match { + case denot: SymDenotation if ctx.stillValid(denot) => + var d: SingleDenotation = denot + do { + d.validFor = Period(ctx.period.runId, d.validFor.firstPhaseId, d.validFor.lastPhaseId) + d = d.nextInRun + } while (d ne denot) + initial.copyIfParentInvalid + case _ => + staleSymbolError + } + /** Produce a denotation that is valid for the given context. * Usually called when !(validFor contains ctx.period) * (even though this is not a precondition). @@ -476,17 +488,6 @@ object Denotations { def current(implicit ctx: Context): SingleDenotation = { val currentPeriod = ctx.period val valid = myValidFor - def bringForward(): SingleDenotation = this match { - case denot: SymDenotation if ctx.stillValid(denot) => - var d: SingleDenotation = denot - do { - d.validFor = Period(currentPeriod.runId, d.validFor.firstPhaseId, d.validFor.lastPhaseId) - d = d.nextInRun - } while (d ne denot) - initial.copyIfParentInvalid - case _ => - staleSymbolError - } if (valid.runId != currentPeriod.runId) bringForward.current else { var cur = this @@ -530,7 +531,7 @@ object Denotations { } def staleSymbolError(implicit ctx: Context) = - throw new Error(s"stale symbol; $this, defined in run ${myValidFor.runId} is referred to in run ${ctx.period.runId}") + throw new StaleSymbol(s"stale symbol; $this, defined in run ${myValidFor.runId} is referred to in run ${ctx.period.runId}") /** For ClassDenotations only: * If caches influenced by parent classes are still valid, the denotation @@ -757,5 +758,7 @@ object Denotations { else NoSymbol } + + class StaleSymbol(msg: String) extends Exception(msg) } -- cgit v1.2.3