File tree 3 files changed +23
-1
lines changed
compiler/src/dotty/tools/dotc
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1056,7 +1056,10 @@ object SymDenotations {
1056
1056
else overriddenFromType(owner.asClass.classInfo.selfType)
1057
1057
1058
1058
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
+ }
1060
1063
1061
1064
/** The symbol overriding this symbol in given subclass `ofclazz`.
1062
1065
*
Original file line number Diff line number Diff line change @@ -179,6 +179,21 @@ class InteractiveDriver(settings: List[String]) extends Driver {
179
179
180
180
private val compiler : Compiler = new InteractiveCompiler
181
181
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
+
182
197
def run (uri : URI , sourceCode : String ): List [MessageContainer ] = {
183
198
val previousCtx = myCtx
184
199
try {
@@ -200,6 +215,7 @@ class InteractiveDriver(settings: List[String]) extends Driver {
200
215
run.compileSources(List (source))
201
216
run.printSummary()
202
217
val t = run.units.head.tpdTree
218
+ cleanup(t)
203
219
myOpenedTrees(uri) = topLevelClassTrees(t, source)
204
220
205
221
reporter.removeBufferedMessages
Original file line number Diff line number Diff line change @@ -92,5 +92,8 @@ object Attachment {
92
92
assert(! getAttachment(key).isDefined, s " duplicate attachment for key $key" )
93
93
next = new Link (key, value, next)
94
94
}
95
+
96
+ final def removeAllAttachments () =
97
+ next = null
95
98
}
96
99
}
You can’t perform that action at this time.
0 commit comments