Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case extractor hover and go to definition are wrong #5508

Open
nicolasstucki opened this issue Aug 3, 2023 · 4 comments
Open

Case extractor hover and go to definition are wrong #5508

nicolasstucki opened this issue Aug 3, 2023 · 4 comments
Labels
bug Something that is making a piece of functionality unusable Scala 3 Generic ticket relating to Scala 3 upstream-fix-needed Waiting on a fix upstream

Comments

@nicolasstucki
Copy link

Describe the bug

object Foo:
  def unapply(x: Int): Option[Int] = ???

def test =
  1 match
    case Foo(n) => // hover on `Foo` or go to the definition of `Foo`
  • If we hover on Foo we see the definition of the object Foo
  • If we go to the definition of Foo we see the definition of the object Foo

Expected behavior

We should see the definition of Foo.unapply and go to that definition.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v1.23.0

Extra context or search terms

No response

@tgodzik tgodzik added bug Something that is making a piece of functionality unusable Scala 3 Generic ticket relating to Scala 3 labels Aug 3, 2023
@tgodzik
Copy link
Contributor

tgodzik commented Aug 3, 2023

Thanks for reporting! Looks like we haven't made it work for unapplies in Scala 3 yet.

Btw. this can now also be fixed inside the compiler repository as we move that part of code to dotty. We will fix it in Metals for older versions and port to dotty. Once we stop publishing for some older versions it will only be done on dotty

@jkciesluk
Copy link
Member

Btw. this can now also be fixed inside the compiler repository as we move that part of code to dotty. We will fix it in Metals for older versions and port to dotty. Once we stop publishing for some older versions it will only be done on dotty

I think this is not the case, because we are not using presentation compiler here. It would be used if there was no definitions found, but we find definition of object Foo. It works in Scala 2, because Foo.unapply is a synthetic occurrence in semanticdb (DefinitionProvider.synthethicApplyOccurence), but it's not there in Scala 3.

@tgodzik
Copy link
Contributor

tgodzik commented Aug 8, 2023

So it seems for hover this is expected and is working as with Scala 2. Should we even show unapply in that case? This qualifies more as a feature request to discuss.

The go to definition is blocked on scala/scala3#13135

@kasiaMarek
Copy link
Contributor

As @tgodzik wrote, go to definition is blocked on scala/scala3#13135. When it comes to hover, it's probably up for discussion what should be shown here, but this is what the interactive compiler returns so this would also require an upstream fix in Scala 3 compiler. Just as a side note, for Scala 2 hover also shows the object not the unapply.

@kasiaMarek kasiaMarek added the upstream-fix-needed Waiting on a fix upstream label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable Scala 3 Generic ticket relating to Scala 3 upstream-fix-needed Waiting on a fix upstream
Projects
None yet
Development

No branches or pull requests

5 participants