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-definition for implicit apply only goes to apply #7267

Open
harpocrates opened this issue Mar 3, 2025 · 4 comments
Open

Go-to-definition for implicit apply only goes to apply #7267

harpocrates opened this issue Mar 3, 2025 · 4 comments
Assignees
Labels
presentation-compiler Something relating to the presentation compiler Scala 2 Scala 3 Generic ticket relating to Scala 3

Comments

@harpocrates
Copy link
Contributor

Describe the bug

Code:

trait Foo {
  def someNum
  def apply(i: Int): Unit = println(someNum)
}
object Bar extends Foo {
  def someNum = 42
}

object Test {
  Bar(2)
}

Cursor on Bar in Bar(2), go-to-definition goes to Foo.apply.

Expected behavior

Go-to definition should report two definitions:

  • object Bar
  • def apply on Foo

LSP is designed to accommodate multiple definitions.

Operating system

Windows

Editor/Extension

VS Code

Version of Metals

1.5.1

Extra context or search terms

No response

@harpocrates
Copy link
Contributor Author

Looks like this used to work but regressed with #7028. The semantic DB path handles this, but not the PC one.

What is the thinking around keeping all of the various alternate codepaths? Should this sort of logic now be reimplemented using the PC?

@kasiaMarek
Copy link
Contributor

What is the thinking around keeping all of the various alternate codepaths?

The idea is that in some conditions some of this strategies may fail, so we have multiple fallbacks. The one that should give the most accurate and up to date solution is used as the first one.

Should this sort of logic now be reimplemented using the PC?

Yeah, ideally behaviour of using semanticdb or pc in compiling code should be the same.

@kasiaMarek kasiaMarek self-assigned this Mar 6, 2025
@kasiaMarek kasiaMarek added Scala 3 Generic ticket relating to Scala 3 Scala 2 and removed Scala 3 Generic ticket relating to Scala 3 labels Mar 6, 2025
@harpocrates
Copy link
Contributor Author

harpocrates commented Mar 6, 2025

Ok, makes sense. I see you self assigned, but let me know if there's anything I can do to help here. I mostly didn't want to go blindly added a parallel code path, but maybe that is what we want in this case.

Long term, sounds like we want at least the preferred strategy to support all features, then the fallbacks can be less expressive.

@kasiaMarek kasiaMarek added Scala 3 Generic ticket relating to Scala 3 presentation-compiler Something relating to the presentation compiler labels Mar 6, 2025
@kasiaMarek
Copy link
Contributor

kasiaMarek commented Mar 6, 2025

I created a PR with a fix for Scala 2, this still needs to be removed similarly in Scala 3. (It leads only to the object and not apply).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
presentation-compiler Something relating to the presentation compiler Scala 2 Scala 3 Generic ticket relating to Scala 3
Projects
None yet
Development

No branches or pull requests

2 participants