Skip to content

Commit

Permalink
Configurable: Accept stale symbol with warning if in IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Jun 6, 2017
1 parent d30a95e commit 638a7c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ object Denotations {
* if denotation is no longer valid.
*/
private def bringForward()(implicit ctx: Context): SingleDenotation = this match {
case denot: SymDenotation if ctx.stillValid(denot) =>
case denot: SymDenotation if ctx.stillValid(denot) || ctx.acceptStale(denot) =>
assert(ctx.runId > validFor.runId || ctx.settings.YtestPickler.value, // mixing test pickler with debug printing can travel back in time
s"denotation $denot invalid in run ${ctx.runId}. ValidFor: $validFor")
var d: SingleDenotation = denot
Expand Down Expand Up @@ -918,13 +918,15 @@ object Denotations {
old.nextInRun = this
}

def staleSymbolError(implicit ctx: Context) = {
def staleSymbolError(implicit ctx: Context) =
throw new StaleSymbol(staleSymbolMsg)

def staleSymbolMsg(implicit ctx: Context): String = {
def ownerMsg = this match {
case denot: SymDenotation => s"in ${denot.owner}"
case _ => ""
}
def msg = s"stale symbol; $this#${symbol.id} $ownerMsg, defined in ${myValidFor}, is referred to in run ${ctx.period}"
throw new StaleSymbol(msg)
s"stale symbol; $this#${symbol.id} $ownerMsg, defined in ${myValidFor}, is referred to in run ${ctx.period}"
}

/** The period (interval of phases) for which there exists
Expand Down
8 changes: 8 additions & 0 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ trait SymDenotations { this: Context =>
explain("denotation is not a SymDenotation")
}
}

/** Configurable: Accept stale symbol with warning if in IDE */
def acceptStale(denot: SingleDenotation): Boolean =
(mode.is(Mode.Interactive) && Config.ignoreStaleInIDE) && {
ctx.warning(denot.staleSymbolMsg)
true
}

}

object SymDenotations {
Expand Down

0 comments on commit 638a7c2

Please sign in to comment.