Skip to content

Commit

Permalink
bugfix: Traverse annotations in NavigateAST
Browse files Browse the repository at this point in the history
Previously, we wouldn't find any symbols inside annotations. Now we do find them correctly.

I wonder if this should also be done in some other places such as TreeAccumulator, I can follow up later with that since it might be a bit more dangerous change
  • Loading branch information
tgodzik committed Sep 19, 2022
1 parent afc6ce4 commit dd904d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/src/dotty/tools/dotc/ast/NavigateAST.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ object NavigateAST {
p.forceIfLazy
case _ =>
}
childPath(p.productIterator, p :: path)
val iterator = p match
case defdef: DefTree[?] =>
p.productIterator ++ defdef.mods.productIterator
case _ =>
p.productIterator
childPath(iterator, p :: path)
}
else {
p match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,10 @@ class HoverTest {
.hover(m1 to m2, hoverContent("Double"))
.hover(m3 to m4, hoverContent("Double"))
}

@Test def annotation: Unit = {
code"""|@${m1}deprecated${m2} def ${m3}x${m4} = 42.0"""
.hover(m1 to m2, hoverContent("deprecated"))
.hover(m3 to m4, hoverContent("Double"))
}
}

0 comments on commit dd904d2

Please sign in to comment.