Skip to content

Commit d474afa

Browse files
committed
Clean up trees after type checking in IDE
1 parent 5f7ef0c commit d474afa

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ class InteractiveDriver(settings: List[String]) extends Driver {
179179

180180
private val compiler: Compiler = new InteractiveCompiler
181181

182+
private def cleanup(tree: tpd.Tree)(implicit ctx: Context): Unit = tree.foreachSubTree { t =>
183+
if (t.hasType) {
184+
if (t.symbol.exists && !t.symbol.isCompleted)
185+
t.symbol.info = UnspecifiedErrorType
186+
}
187+
t.removeAllAttachments()
188+
}
189+
182190
def run(uri: URI, sourceCode: String): List[MessageContainer] = {
183191
val previousCtx = myCtx
184192
try {
@@ -200,6 +208,7 @@ class InteractiveDriver(settings: List[String]) extends Driver {
200208
run.compileSources(List(source))
201209
run.printSummary()
202210
val t = run.units.head.tpdTree
211+
cleanup(t)
203212
myOpenedTrees(uri) = topLevelClassTrees(t, source)
204213

205214
reporter.removeBufferedMessages

compiler/src/dotty/tools/dotc/util/Attachment.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,8 @@ object Attachment {
9292
assert(!getAttachment(key).isDefined, s"duplicate attachment for key $key")
9393
next = new Link(key, value, next)
9494
}
95+
96+
final def removeAllAttachments() =
97+
next = null
9598
}
9699
}

0 commit comments

Comments
 (0)