Skip to content

Commit 3145088

Browse files
authored
Merge pull request #356 from scala/backport-lts-3.3-22973
Backport "fix: show hover for synthetics if explicitly used" to 3.3 LTS
2 parents 07752e8 + 8571068 commit 3145088

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,6 @@ object MetalsInteractive:
216216
if head.symbol.is(Exported) then
217217
val sym = head.symbol.sourceSymbol
218218
List((sym, sym.info, None))
219-
else if head.symbol.is(Synthetic) then
220-
enclosingSymbolsWithExpressionType(
221-
tail,
222-
pos,
223-
indexed,
224-
skipCheckOnName
225-
)
226219
else if head.symbol != NoSymbol then
227220
if skipCheckOnName ||
228221
MetalsInteractive.isOnName(
@@ -231,6 +224,13 @@ object MetalsInteractive:
231224
indexed.ctx.source
232225
)
233226
then List((head.symbol, head.typeOpt, None))
227+
else if head.symbol.is(Synthetic) then
228+
enclosingSymbolsWithExpressionType(
229+
tail,
230+
pos,
231+
indexed,
232+
skipCheckOnName
233+
)
234234
/* Type tree for List(1) has an Int type variable, which has span
235235
* but doesn't exist in code.
236236
* https://github.com/lampepfl/dotty/issues/15937

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

+13
Original file line numberDiff line numberDiff line change
@@ -718,3 +718,16 @@ class HoverTermSuite extends BaseHoverSuite:
718718
"""def ???: Nothing""".stripMargin.hover
719719
)
720720

721+
@Test def `value-of`: Unit =
722+
check(
723+
"""|enum Foo(val key: String) {
724+
| case Bar extends Foo("b")
725+
| case Baz extends Foo("z")
726+
|}
727+
|
728+
|object Foo {
729+
| def parse(key: String) = Foo.va@@lueOf("b")
730+
|
731+
|""".stripMargin,
732+
"def valueOf($name: String): Foo".hover
733+
)

0 commit comments

Comments
 (0)