Skip to content

Commit 1eef8dd

Browse files
committed
Use untpd.TreeTraverser in namedTrees
Avoids repeated crashes when hitting a tree that exists only in untyped form.
1 parent 638a7c2 commit 1eef8dd

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

compiler/src/dotty/tools/dotc/config/Config.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,6 @@ object Config {
167167
*/
168168
final val PendingFindMemberLimit = LogPendingFindMemberThreshold * 4
169169

170+
/** When in IDE, turn StaleSymbol errors into warnings instead of crashing */
170171
final val ignoreStaleInIDE = true
171172
}

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,20 @@ object Interactive {
131131
val buf = new mutable.ListBuffer[SourceTree]
132132

133133
trees foreach { case SourceTree(topTree, source) =>
134-
(new TreeTraverser {
135-
override def traverse(tree: Tree)(implicit ctx: Context) = {
134+
(new untpd.TreeTraverser {
135+
override def traverse(tree: untpd.Tree)(implicit ctx: Context) = {
136136
tree match {
137-
case _: Inlined =>
137+
case _: untpd.Inlined =>
138138
// Skip inlined trees
139-
case tree: NameTree
140-
if tree.symbol.exists
141-
&& !tree.symbol.is(Synthetic)
142-
&& tree.pos.exists
143-
&& !tree.pos.isZeroExtent
144-
&& (includeReferences || isDefinition(tree))
145-
&& treePredicate(tree) =>
146-
buf += SourceTree(tree, source)
139+
case utree: untpd.NameTree if tree.hasType =>
140+
val tree = utree.asInstanceOf[tpd.NameTree]
141+
if (tree.symbol.exists
142+
&& !tree.symbol.is(Synthetic)
143+
&& tree.pos.exists
144+
&& !tree.pos.isZeroExtent
145+
&& (includeReferences || isDefinition(tree))
146+
&& treePredicate(tree))
147+
buf += SourceTree(tree, source)
147148
case _ =>
148149
}
149150
traverseChildren(tree)

0 commit comments

Comments
 (0)