Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden IDE, 2nd attempt #2692

Merged
merged 6 commits into from Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
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
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a warning will popup in the IDE (not currently because we ignore warnings without positions, but that's just because of an issue in the LSP (microsoft/language-server-protocol#249)), maybe use ctx.debug instead ?

true
}

}

object SymDenotations {
Expand Down