Skip to content

Commit 26185f6

Browse files
committed
Merge pull request #116 from dotty-staging/add/Denotation-update
Install method for SymDenotations
2 parents 839a9fc + e1713aa commit 26185f6

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,30 @@ object Denotations {
572572
}
573573
}
574574

575+
/** Install this denotation to be the result of the given denotation transformer.
576+
* This is the implementation of the same-named method in SymDenotations.
577+
* It's placed here because it needs access to private fields of SingleDenotation.
578+
*/
579+
protected def installAfter(phase: DenotTransformer)(implicit ctx: Context): Unit = {
580+
val targetId = phase.next.id
581+
assert(ctx.phaseId == targetId,
582+
s"denotation update for $this called in phase ${ctx.phase}, expected was ${phase.next}")
583+
val current = symbol.current
584+
this.nextInRun = current.nextInRun
585+
this.validFor = Period(ctx.runId, targetId, current.validFor.lastPhaseId)
586+
if (current.validFor.firstPhaseId == targetId) {
587+
// replace current with this denotation
588+
var prev = current
589+
while (prev.nextInRun ne current) prev = prev.nextInRun
590+
prev.nextInRun = this
591+
}
592+
else {
593+
// insert this denotation after current
594+
current.validFor = Period(ctx.runId, current.validFor.firstPhaseId, targetId - 1)
595+
current.nextInRun = this
596+
}
597+
}
598+
575599
def staleSymbolError(implicit ctx: Context) = {
576600
def ownerMsg = this match {
577601
case denot: SymDenotation => s"in ${denot.owner}"

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ object SymDenotations {
752752

753753
def debugString = toString+"#"+symbol.id // !!! DEBUG
754754

755-
// ----- copies ------------------------------------------------------
755+
// ----- copies and transforms ----------------------------------------
756756

757757
protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new UniqueRefDenotation(s, i, validFor)
758758

@@ -774,6 +774,10 @@ object SymDenotations {
774774
d.annotations = annotations1
775775
d
776776
}
777+
778+
/** Install this denotation as the result of the given denotation transformer. */
779+
override def installAfter(phase: DenotTransformer)(implicit ctx: Context): Unit =
780+
super.installAfter(phase)
777781
}
778782

779783
/** The contents of a class definition during a period

0 commit comments

Comments
 (0)