aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala24
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala6
2 files changed, 29 insertions, 1 deletions
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}"
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index e96f08855..7762f61dd 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -752,7 +752,7 @@ object SymDenotations {
def debugString = toString+"#"+symbol.id // !!! DEBUG
- // ----- copies ------------------------------------------------------
+ // ----- copies and transforms ----------------------------------------
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new UniqueRefDenotation(s, i, validFor)
@@ -774,6 +774,10 @@ object SymDenotations {
d.annotations = annotations1
d
}
+
+ /** Install this denotation as the result of the given denotation transformer. */
+ override def installAfter(phase: DenotTransformer)(implicit ctx: Context): Unit =
+ super.installAfter(phase)
}
/** The contents of a class definition during a period