Skip to content

Commit b85547d

Browse files
authored
Merge pull request #482 from scala/backport-lts-3.3-23454
Backport "fix: Inconsistent annotation tooltips" to 3.3 LTS
2 parents 29f7f37 + 495c4c8 commit b85547d

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ object NavigateAST {
141141
case _ =>
142142
val iterator = p match
143143
case defdef: DefTree[?] =>
144-
p.productIterator ++ defdef.mods.productIterator
144+
val mods = defdef.mods
145+
val annotations = defdef.symbol.annotations.filter(_.tree.span.contains(span)).map(_.tree)
146+
p.productIterator ++ annotations ++ mods.productIterator
145147
case _ =>
146148
p.productIterator
147149
childPath(iterator, p :: path)

presentation-compiler/test/dotty/tools/pc/tests/hover/HoverDefnSuite.scala

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,51 @@ class HoverDefnSuite extends BaseHoverSuite:
255255
|```
256256
|""".stripMargin
257257
)
258+
259+
@Test def `annotation` =
260+
check(
261+
"""|
262+
|@ma@@in
263+
|def example() =
264+
| println("test")
265+
|""".stripMargin,
266+
"""|```scala
267+
|def this(): main
268+
|```""".stripMargin.hover
269+
)
270+
271+
@Test def `annotation-2` =
272+
check(
273+
"""|
274+
|@ma@@in
275+
|def example() =
276+
| List("test")
277+
|""".stripMargin,
278+
"""|```scala
279+
|def this(): main
280+
|```""".stripMargin.hover
281+
)
282+
283+
@Test def `annotation-3` =
284+
check(
285+
"""|
286+
|@ma@@in
287+
|def example() =
288+
| Array("test")
289+
|""".stripMargin,
290+
"""|```scala
291+
|def this(): main
292+
|```""".stripMargin.hover
293+
)
294+
295+
@Test def `annotation-4` =
296+
check(
297+
"""|
298+
|@ma@@in
299+
|def example() =
300+
| Array(1, 2)
301+
|""".stripMargin,
302+
"""|```scala
303+
|def this(): main
304+
|```""".stripMargin.hover
305+
)

0 commit comments

Comments
 (0)