diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/MetalsInteractive.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/MetalsInteractive.scala index c5b04ab9efb..29af349da11 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/MetalsInteractive.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/MetalsInteractive.scala @@ -241,7 +241,13 @@ object MetalsInteractive: */ else if head.isInstanceOf[TypeTree] then enclosingSymbolsWithExpressionType(tail, pos, indexed) - else Nil + else + path match + case (_: ValDef) :: (t : Template) :: _ => + t.body.collectFirst { + case d: ValDef if d.nameSpan.contains(pos.span) => List((d.symbol, d.symbol.info)) + }.getOrElse(Nil) + case _ => Nil else val recovered = recoverError(head, indexed) if recovered.isEmpty then diff --git a/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala b/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala index 38e90114900..da84b6856d9 100644 --- a/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala +++ b/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala @@ -773,4 +773,14 @@ class HoverTermSuite extends BaseHoverSuite { ) ) + check( + "i7012".tag(IgnoreScala2), + """|object O { + | val x@@x, yy, zz = 1 + |} + |""".stripMargin, + """| + |val xx: Int + |""".stripMargin.hover + ) }