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

Go to Implementation doesn't find anonymous instantiations with SAM conversion #5868

Closed
filipwiech opened this issue Nov 23, 2023 · 4 comments

Comments

@filipwiech
Copy link
Contributor

filipwiech commented Nov 23, 2023

Describe the bug

Recently I was confused as Metals couldn't find any implementation of a type in the project, even thought it had to be used somewhere. Turns out that Go to Implementation is unable to find anonymous instantiations if SAM conversion is applied. Example, only test3 and test4 are shown when trying to search for the MyTestTrait implementations:

// applies to abstract classes too
trait MyTestTrait {
  def compute(input: Int): Int
}

// MyTestObject could be a class, trait, etc.
object MyTestObject {

  val test1: MyTestTrait = (input: Int) => input + 1
  def test2: MyTestTrait = (input: Int) => input + 2

  val test3: MyTestTrait = new MyTestTrait {
    def compute(input: Int): Int = input + 3
  }
  def test4: MyTestTrait = new MyTestTrait {
    def compute(input: Int): Int = input + 4
  }

}

Tested on Scala 2.13.

Expected behavior

All implementations are shown by Metals, including the test1 and test2 in the provided code sample.

Operating system

Linux

Editor/Extension

VS Code

Version of Metals

1.1.0+100-58b80be5-SNAPSHOT

Extra context or search terms

go to implementation, SAM, anonymous type, class, trait

@kasiaMarek
Copy link
Contributor

Thanks for the report. Go to implementation bases on SemanticDB, which doesn't produce an anonymous class for SAM conversion both in Scala 2 and Scala 3.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 24, 2023

We also have an issue already about that, but thanks for reminding us! #4596

@tgodzik tgodzik closed this as completed Nov 24, 2023
@filipwiech
Copy link
Contributor Author

filipwiech commented Nov 24, 2023

@kasiaMarek Thank you for the explanation! 👍 Is there an upstream ticket that could be tracked? 🙂
@tgodzik Oops, sorry about that, my bad for not noticing this earlier. I had filed the issue late at night after getting a reproduction and haven't thought to check. 😅

@tgodzik
Copy link
Contributor

tgodzik commented Nov 27, 2023

I raised it in scalameta/scalameta#3394

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants