Skip to content

Commit

Permalink
Make pathTo handle new pattern recovery mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
rochala committed Aug 28, 2024
1 parent 009fc63 commit a9ac829
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions compiler/src/dotty/tools/dotc/ast/NavigateAST.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ object NavigateAST {
var bestFit: List[Positioned] = path
while (it.hasNext) do
val path1 = it.next() match
case sel: untpd.Select if isTreeFromRecovery(sel) => path
case sel: untpd.Select if isRecoveryTree(sel) => path
case sel: untpd.Ident if isPatternRecoveryTree(sel) => path
case p: Positioned if !p.isInstanceOf[Closure[?]] => singlePath(p, path)
case m: untpd.Modifiers => childPath(m.productIterator, path)
case xs: List[?] => childPath(xs.iterator, path)
Expand Down Expand Up @@ -106,9 +107,12 @@ object NavigateAST {
bestSpan.contains(candidateSpan) && bestSpan.isSynthetic && !candidateSpan.isSynthetic
else false

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

def isTreeFromRecovery(p: untpd.Select): Boolean =
p.name == StdNames.nme.??? && p.qualifier.symbol.name == StdNames.nme.Predef && p.span.isSynthetic
def isPatternRecoveryTree(ident: untpd.Ident): Boolean =
ident.span.isSynthetic && StdNames.nme.WILDCARD == ident.name

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

0 comments on commit a9ac829

Please sign in to comment.