From e1713aa311cf3bee7fb52e7eaefa481097a72a82 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 4 Apr 2014 18:13:04 +0200 Subject: Install method for SymDenotations Add a new method to install a SymDenotation after a specific phase has run. The new denotation replaces the current denotation of the symbol starting with the period after the given phase. --- src/dotty/tools/dotc/core/Denotations.scala | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (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 1e3dec255..e9b9b20c4 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -572,6 +572,30 @@ object Denotations { } } + /** Install this denotation to be the result of the given denotation transformer. + * This is the implementation of the same-named method in SymDenotations. + * It's placed here because it needs access to private fields of SingleDenotation. + */ + 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 + 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 + } + else { + // insert this denotation after current + current.validFor = Period(ctx.runId, current.validFor.firstPhaseId, targetId - 1) + current.nextInRun = this + } + } + def staleSymbolError(implicit ctx: Context) = { def ownerMsg = this match { case denot: SymDenotation => s"in ${denot.owner}" -- cgit v1.2.3