Skip to content

Commit c3ba2f4

Browse files
authored
bugfix: Traverse annotations in NavigateAST (#16071)
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
2 parents 175debf + dd904d2 commit c3ba2f4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/ast/NavigateAST.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ object NavigateAST {
111111
p.forceIfLazy
112112
case _ =>
113113
}
114-
childPath(p.productIterator, p :: path)
114+
val iterator = p match
115+
case defdef: DefTree[?] =>
116+
p.productIterator ++ defdef.mods.productIterator
117+
case _ =>
118+
p.productIterator
119+
childPath(iterator, p :: path)
115120
}
116121
else {
117122
p match {

language-server/test/dotty/tools/languageserver/HoverTest.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,10 @@ class HoverTest {
244244
.hover(m1 to m2, hoverContent("Double"))
245245
.hover(m3 to m4, hoverContent("Double"))
246246
}
247+
248+
@Test def annotation: Unit = {
249+
code"""|@${m1}deprecated${m2} def ${m3}x${m4} = 42.0"""
250+
.hover(m1 to m2, hoverContent("deprecated"))
251+
.hover(m3 to m4, hoverContent("Double"))
252+
}
247253
}

0 commit comments

Comments
 (0)