Skip to content

Commit 2078b74

Browse files
committed
fix: show hover for synthetics if explicitly used
1 parent 98c84c3 commit 2078b74

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,6 @@ object MetalsInteractive:
230230
if head.symbol.is(Exported) then
231231
val sym = head.symbol.sourceSymbol
232232
List((sym, sym.info, None))
233-
else if head.symbol.is(Synthetic) then
234-
enclosingSymbolsWithExpressionType(
235-
tail,
236-
pos,
237-
indexed,
238-
skipCheckOnName
239-
)
240233
else if head.symbol != NoSymbol then
241234
if skipCheckOnName ||
242235
MetalsInteractive.isOnName(
@@ -245,6 +238,13 @@ object MetalsInteractive:
245238
indexed.ctx.source
246239
)
247240
then List((head.symbol, head.typeOpt, None))
241+
else if head.symbol.is(Synthetic) then
242+
enclosingSymbolsWithExpressionType(
243+
tail,
244+
pos,
245+
indexed,
246+
skipCheckOnName
247+
)
248248
/* Type tree for List(1) has an Int type variable, which has span
249249
* but doesn't exist in code.
250250
* https://github.com/scala/scala3/issues/15937

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

+14
Original file line numberDiff line numberDiff line change
@@ -744,3 +744,17 @@ class HoverTermSuite extends BaseHoverSuite:
744744
|""".stripMargin,
745745
"name: String".hover
746746
)
747+
748+
@Test def `value-of`: Unit =
749+
check(
750+
"""|enum Foo(val key: String) {
751+
| case Bar extends Foo("b")
752+
| case Baz extends Foo("z")
753+
|}
754+
|
755+
|object Foo {
756+
| def parse(key: String) = Foo.va@@lueOf("b")
757+
|
758+
|""".stripMargin,
759+
"def valueOf($name: String): Foo".hover
760+
)

0 commit comments

Comments
 (0)