scalameta / scalameta

Library to read, analyze, transform and generate Scala programs
http://scalameta.org/
BSD 3-Clause "New" or "Revised" License
1.11k stars 223 forks source link

Goto definition doesn't work for classOf #1856

Closed tgodzik closed 5 years ago

tgodzik commented 5 years ago

Describe the bug Go to definition doesn't work when class is in classOf[]

To Reproduce Steps to reproduce the behavior:

  1. Create any classOf[], for example classOf[Boolean]
  2. Try to goto on Boolean
  3. No definition available

Expected behavior Lsp would go to definition of the class inside classOf[]

Screenshots bug

Installation:

Search terms goto definition classOf

olafurpg commented 5 years ago

Thank you for reporting! This is a SemanticDB bug, a test case reproducing the issue is already commited in the repo here https://github.com/scalameta/scalameta/blob/ff542e7c5b937822c12d0aa1ef7d6ab92b2fc5e1/tests/jvm/src/test/resources/example/Types.scala#L114

- obtained
+ expected
- final val clazzOf/*<=types.Test.Literal.clazzOf.*/ = classOf[Option[Int]] 
+  final val clazzOf/*<=types.Test.Literal.clazzOf.*/ = classOf[Option/*=>scala.Option#*/[Int/*=>scala.Int#*/]] 
olafurpg commented 5 years ago

Looks like there's nothing we can do on our side, this needs to be fixed upstream in the compiler. Definition used to work for classOf in older versions of SemanticDB when we instrumented the typer but this was removed in https://github.com/scalameta/scalameta/pull/1804 to simplify compiler upgrades and improve interoperability with other compiler plugins.