From c38970b9816d797c41afe83862642673839c4d52 Mon Sep 17 00:00:00 2001 From: kasiaMarek Date: Fri, 11 Apr 2025 13:19:20 +0200 Subject: [PATCH 1/2] fix: show hover for synthetics if explicitly used --- .../main/dotty/tools/pc/MetalsInteractive.scala | 14 +++++++------- .../tools/pc/tests/hover/HoverTermSuite.scala | 13 +++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala b/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala index f5de56711118..8c3e52080c93 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala @@ -216,13 +216,6 @@ object MetalsInteractive: if head.symbol.is(Exported) then val sym = head.symbol.sourceSymbol List((sym, sym.info, None)) - else if head.symbol.is(Synthetic) then - enclosingSymbolsWithExpressionType( - tail, - pos, - indexed, - skipCheckOnName - ) else if head.symbol != NoSymbol then if skipCheckOnName || MetalsInteractive.isOnName( @@ -231,6 +224,13 @@ object MetalsInteractive: indexed.ctx.source ) then List((head.symbol, head.typeOpt, None)) + else if head.symbol.is(Synthetic) then + enclosingSymbolsWithExpressionType( + tail, + pos, + indexed, + skipCheckOnName + ) /* Type tree for List(1) has an Int type variable, which has span * but doesn't exist in code. * https://github.com/lampepfl/dotty/issues/15937 diff --git a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala index 6f682139506e..b2170d0e32b5 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala @@ -718,3 +718,16 @@ class HoverTermSuite extends BaseHoverSuite: """def ???: Nothing""".stripMargin.hover ) + @Test def `value-of`: Unit = + check( + """|enum Foo(val key: String) { + | case Bar extends Foo("b") + | case Baz extends Foo("z") + |} + | + |object Foo { + | def parse(key: String) = Foo.va@@lueOf("b") + | + |""".stripMargin, + "def valueOf($name: String): Foo".hover + ) From 85710688ee84533d372878b10c63da000d780428 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Mon, 28 Apr 2025 10:58:19 +0200 Subject: [PATCH 2/2] fix: show hover for synthetics if explicitly used [Cherry-picked 2078b746b23675393fb5ba3789adfe9ed0e162ff][modified]