scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.09k stars 330 forks source link

Go to definition of extension method does not work if extendible type is specifiied #5026

Open GiGurra opened 1 year ago

GiGurra commented 1 year ago

Describe the bug

Using Metals in VsCode

Minimum reproducible case:

object Mincase:

  extension [X](x: X)
    def foobar(): Unit = ???

  1.foobar() // compiles and can jump to definition above
  (1: Int).foobar() // compiles but cannot jump to definition above

Expected behavior

Should be possible to jump to definition in both cases above

Operating system

Windows

Editor/Extension

VS Code

Version of Metals

0.11.11

Extra context or search terms

No response

jkciesluk commented 1 year ago

Hi, thanks for reporting!

The problem is the positions are incorrect

extension [X](x: X)
    def foobar(): Unit = ???

val x = (1: Int).foobar()
// <<>> show how compiler sees position of foobar
val x = <<(1: In>>t).foobar()

For the same reason, features like highlight and semantic tokens aren't working. We can do a simple workaround in metals to make those features work, but Go to definition uses semanticdb, which might require upstream fix.