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 + )