aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-06 21:53:56 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-06 21:55:17 +0100
commit0d356254c4d6326398c9c1a587ad193fadef6883 (patch)
treeefca748e4e2278c675a2880cc0b31927272aa6c9
parentab62ca99a31ccd1984b875f7040b430bfccc2724 (diff)
downloaddotty-0d356254c4d6326398c9c1a587ad193fadef6883.tar.gz
dotty-0d356254c4d6326398c9c1a587ad193fadef6883.tar.bz2
dotty-0d356254c4d6326398c9c1a587ad193fadef6883.zip
Catch stale references
If a NamedType was denoted a SymDenotation one run, but stops being defined in the next, throw a staleSymbol error.
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala5
-rw-r--r--src/dotty/tools/dotc/core/Types.scala8
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala4
3 files changed, 10 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index e6d5023e5..90a6a373c 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -479,7 +479,7 @@ object Denotations {
} while (d ne denot)
initial.copyIfParentInvalid
case _ =>
- throw new Error(s"stale symbol; $this, defined in run ${valid.runId} is referred to in run ${currentPeriod.runId}")
+ staleSymbolError
}
if (valid.runId != currentPeriod.runId) bringForward.current
else {
@@ -523,6 +523,9 @@ object Denotations {
}
}
+ def staleSymbolError(implicit ctx: Context) =
+ throw new Error(s"stale symbol; $this, defined in run ${myValidFor.runId} is referred to in run ${ctx.period.runId}")
+
/** For ClassDenotations only:
* If caches influenced by parent classes are still valid, the denotation
* itself, otherwise a freshly initialized copy.
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 2a6a5017f..28a7f9e67 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1018,8 +1018,12 @@ object Types {
case null =>
val sym = lastSymbol
if (sym == null) loadDenot else denotOfSym(sym)
- case d: SymDenotation if ctx.stillValid(d) =>
- d.current
+ case d: SymDenotation =>
+ if (ctx.stillValid(d)) d.current
+ else {
+ val newd = loadDenot
+ if (newd.exists) newd else d.staleSymbolError
+ }
case d =>
if (d.validFor.runId == ctx.period.runId) d.current
else loadDenot
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index a153f9066..868276598 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -204,10 +204,6 @@ object Inferencing {
*/
abstract case class ViewProto(argType: Type, override val resultType: Type)(implicit ctx: Context)
extends CachedGroundType with ApplyingProto {
- // def lookingForInfo = resultType match {
- // case rt: SelectionProto => rt.name.toString == "info"
- // case _ => false
- // }
def isMatchedBy(tp: Type)(implicit ctx: Context): Boolean = /*ctx.conditionalTraceIndented(lookingForInfo, i"?.info isMatchedBy $tp ${tp.getClass}")*/ {
ctx.typer.isApplicable(tp, argType :: Nil, resultType)
}