File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1056,7 +1056,10 @@ object SymDenotations {
10561056 else overriddenFromType(owner.asClass.classInfo.selfType)
10571057
10581058 private def overriddenFromType (tp : Type )(implicit ctx : Context ): Iterator [Symbol ] =
1059- tp.baseClasses.tail.iterator map overriddenSymbol filter (_.exists)
1059+ tp.baseClasses match {
1060+ case _ :: inherited => inherited.iterator map overriddenSymbol filter (_.exists)
1061+ case Nil => Iterator .empty
1062+ }
10601063
10611064 /** The symbol overriding this symbol in given subclass `ofclazz`.
10621065 *
Original file line number Diff line number Diff line change @@ -179,6 +179,21 @@ class InteractiveDriver(settings: List[String]) extends Driver {
179179
180180 private val compiler : Compiler = new InteractiveCompiler
181181
182+ /** Remove attachments and error out completers. The goal is to avoid
183+ * having a completer hanging in a typed tree which can capture the context
184+ * of a previous run. Note that typed trees can have untyped or partially
185+ * typed children if the source contains errors.
186+ */
187+ private def cleanup (tree : tpd.Tree )(implicit ctx : Context ): Unit = tree.foreachSubTree { t =>
188+ if (t.hasType) {
189+ if (t.symbol.exists) {
190+ if (! t.symbol.isCompleted) t.symbol.info = UnspecifiedErrorType
191+ t.symbol.annotations.foreach(annot => cleanup(annot.tree))
192+ }
193+ }
194+ t.removeAllAttachments()
195+ }
196+
182197 def run (uri : URI , sourceCode : String ): List [MessageContainer ] = {
183198 val previousCtx = myCtx
184199 try {
@@ -200,6 +215,7 @@ class InteractiveDriver(settings: List[String]) extends Driver {
200215 run.compileSources(List (source))
201216 run.printSummary()
202217 val t = run.units.head.tpdTree
218+ cleanup(t)
203219 myOpenedTrees(uri) = topLevelClassTrees(t, source)
204220
205221 reporter.removeBufferedMessages
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments