aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Denotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-04-04 18:13:04 +0200
committerMartin Odersky <odersky@gmail.com>2014-04-04 18:18:18 +0200
commite1713aa311cf3bee7fb52e7eaefa481097a72a82 (patch)
tree17303a8589b8e2dfa12ee13a98daf296b72ca691 /src/dotty/tools/dotc/core/Denotations.scala
parentfa098bd5fac8a5f3edc7392b24d4b4da45a47c1a (diff)
downloaddotty-e1713aa311cf3bee7fb52e7eaefa481097a72a82.tar.gz
dotty-e1713aa311cf3bee7fb52e7eaefa481097a72a82.tar.bz2
dotty-e1713aa311cf3bee7fb52e7eaefa481097a72a82.zip
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.
Diffstat (limited to 'src/dotty/tools/dotc/core/Denotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala24
1 files changed, 24 insertions, 0 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}"