Skip to content

Fix IDE crash on @AfterClass #3027

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,24 @@ class InteractiveDriver(settings: List[String]) extends Driver {
* of a previous run. Note that typed trees can have untyped or partially
* typed children if the source contains errors.
*/
private def cleanup(tree: tpd.Tree)(implicit ctx: Context): Unit = tree.foreachSubTree { t =>
if (t.hasType) {
if (t.symbol.exists) {
if (!t.symbol.isCompleted) t.symbol.info = UnspecifiedErrorType
t.symbol.annotations.foreach(annot => cleanup(annot.tree))
private def cleanup(tree: tpd.Tree)(implicit ctx: Context): Unit = {
val cleanedTree = mutable.Set.empty[tpd.Tree]
Copy link
Member

@smarter smarter Sep 12, 2017

Choose a reason for hiding this comment

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

I think I would call this variable seen, this is the name we commonly use in the compiler for cycle detection.

def cleanupTree(tree: tpd.Tree): Unit = {
cleanedTree += tree
tree.foreachSubTree { t =>
if (t.hasType) {
if (t.symbol.exists) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (t.hasType && t.symbol.exists) ?

if (!t.symbol.isCompleted) t.symbol.info = UnspecifiedErrorType
t.symbol.annotations.foreach { annot =>
if (!cleanedTree(annot.tree))
cleanupTree(annot.tree)
}
}
}
t.removeAllAttachments()
}
}
t.removeAllAttachments()
cleanupTree(tree)
}

def run(uri: URI, sourceCode: String): List[MessageContainer] = {
Expand Down