aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-09 13:35:17 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-09 19:01:00 +0100
commitf4e9a881a561e28900becc7deea520b43e57fb31 (patch)
tree04cda6a1f41717587fcb3ecb7c9e2a5cb59ac4ec /src/dotty/tools/dotc/core/SymDenotations.scala
parentada0febcb0893ff8f87d01f605a43f731e38a0be (diff)
downloaddotty-f4e9a881a561e28900becc7deea520b43e57fb31.tar.gz
dotty-f4e9a881a561e28900becc7deea520b43e57fb31.tar.bz2
dotty-f4e9a881a561e28900becc7deea520b43e57fb31.zip
WIP: Fixes to bring symbols forward
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index d9fa15a5f..f6d86bd20 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -33,14 +33,23 @@ trait SymDenotations { this: Context =>
if (initFlags is Package) new PackageClassDenotation(symbol, owner, name, initFlags, initInfo, initPrivateWithin)
else new ClassDenotation(symbol, owner, name, initFlags, initInfo, initPrivateWithin)
else new SymDenotation(symbol, owner, name, initFlags, initInfo, initPrivateWithin)
+ result.firstRunId = ctx.runId
result.validFor = stablePeriod
result
}
- def stillValid(denot: SymDenotation): Boolean =
+ def stillValid(denot: SymDenotation): Boolean = try
if (denot is ValidForever) true
else if (denot.owner is PackageClass) denot.owner.decls.lookup(denot.name) eq denot.symbol
- else stillValid(denot.owner)
+ else
+ stillValid(denot.owner) && (
+ (denot.owner.firstRunId == denot.firstRunId) || {
+ println(s"no longer valid: $denot, was defined in ${denot.firstRunId}, owner ${denot.owner} was defined in ${denot.owner.firstRunId}")
+ false
+ })
+ catch {
+ case ex: StaleSymbol => false
+ }
}
object SymDenotations {
@@ -60,6 +69,8 @@ object SymDenotations {
override def hasUniqueSym: Boolean = exists
+ private[SymDenotations] var firstRunId: RunId = _
+
// ------ Getting and setting fields -----------------------------
private[this] var myFlags: FlagSet = adaptFlags(initFlags)
@@ -720,6 +731,8 @@ object SymDenotations {
val annotations1 = if (annotations != null) annotations else this.annotations
val d = ctx.SymDenotation(symbol, owner, name, initFlags1, info1, privateWithin1)
d.annotations = annotations1
+ d.firstRunId = firstRunId
+ // what about validFor?
d
}
}
@@ -787,13 +800,37 @@ object SymDenotations {
/** Are caches influenced by parent classes still valid? */
private def parentsAreValid(implicit ctx: Context): Boolean =
parentDenots == null ||
- parentDenots.corresponds(myClassParents)(_ eq _.denot)
+ parentDenots.corresponds(myClassParents map (_.denot))(_ eq _)
+
+ private var copied = 0
/** If caches influenced by parent classes are still valid, the denotation
* itself, otherwise a freshly initialized copy.
*/
override def copyIfParentInvalid(implicit ctx: Context): SingleDenotation =
- if (!parentsAreValid) copySymDenotation() else this
+ if (!parentsAreValid) {
+ println(s"parents of $this are invalid; copying $hashCode, symbol id = ${symbol.id} ...")
+ for ((pd1, pd2) <- parentDenots zip (myClassParents map (_.denot)))
+ if (pd1 ne pd2) println(s"different: $pd1 != $pd2")
+ if (name.toString == "Context")
+ new Error().printStackTrace()
+ assert(copied == 0)
+ copied += 1
+ copySymDenotation()
+ }
+ else this
+
+ protected override def bringForward()(implicit ctx: Context): SingleDenotation = {
+ if (name.toString == "Context") println(s"bring forward $this, id = ${symbol.id}, defunid = ${symbol.defRunId}, ctx.runid = ${ctx.runId}")
+ assert(ctx.runId >= symbol.defRunId, s"$this, defrunid = ${symbol.defRunId}, ctx.runid = ${ctx.runId}")
+ if (symbol.defRunId == ctx.runId) symbol.denot
+ else {
+ val d = super.bringForward()
+ symbol.denot = d.asSymDenotation
+ if (name.toString == "Context") println(s"brought forward $d, id = ${symbol.id}, defunid = ${symbol.defRunId}")
+ d
+ }
+ }
// ------ class-specific operations -----------------------------------