Skip to content

Commit a9ac829

Browse files
committed
Make pathTo handle new pattern recovery mechanism
1 parent 009fc63 commit a9ac829

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: compiler/src/dotty/tools/dotc/ast/NavigateAST.scala

+7-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ object NavigateAST {
7777
var bestFit: List[Positioned] = path
7878
while (it.hasNext) do
7979
val path1 = it.next() match
80-
case sel: untpd.Select if isTreeFromRecovery(sel) => path
80+
case sel: untpd.Select if isRecoveryTree(sel) => path
81+
case sel: untpd.Ident if isPatternRecoveryTree(sel) => path
8182
case p: Positioned if !p.isInstanceOf[Closure[?]] => singlePath(p, path)
8283
case m: untpd.Modifiers => childPath(m.productIterator, path)
8384
case xs: List[?] => childPath(xs.iterator, path)
@@ -106,9 +107,12 @@ object NavigateAST {
106107
bestSpan.contains(candidateSpan) && bestSpan.isSynthetic && !candidateSpan.isSynthetic
107108
else false
108109

110+
def isRecoveryTree(sel: untpd.Select): Boolean =
111+
sel.span.isSynthetic
112+
&& (sel.name == StdNames.nme.??? && sel.qualifier.symbol.name == StdNames.nme.Predef)
109113

110-
def isTreeFromRecovery(p: untpd.Select): Boolean =
111-
p.name == StdNames.nme.??? && p.qualifier.symbol.name == StdNames.nme.Predef && p.span.isSynthetic
114+
def isPatternRecoveryTree(ident: untpd.Ident): Boolean =
115+
ident.span.isSynthetic && StdNames.nme.WILDCARD == ident.name
112116

113117
def envelops(a: Span, b: Span): Boolean =
114118
!b.exists || a.exists && (

0 commit comments

Comments
 (0)