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

Scala partially qualified symbol not inferred #13740

Closed
stuhood opened this issue Nov 30, 2021 · 3 comments · Fixed by #13775
Closed

Scala partially qualified symbol not inferred #13740

stuhood opened this issue Nov 30, 2021 · 3 comments · Fixed by #13775
Assignees

Comments

@stuhood
Copy link
Member

stuhood commented Nov 30, 2021

Code like:

import akka.http.javadsl.{ model => jm }

sealed trait ContentRange extends jm.ContentRange ... {

...will not infer a dependency on the symbol akka.http.javadsl.model.ContentRange.

@stuhood
Copy link
Member Author

stuhood commented Nov 30, 2021

This represented roughly 12% of the issues in akka-http.

@stuhood
Copy link
Member Author

stuhood commented Dec 1, 2021

It seems like completely solving this would amount to implementing symbol resolution such that we could differentiate between using a field of a local variable (val lib = ...) and using a relative import (import x.lib).

But since we do not need 100% accuracy here, it seems like an imports-only-aware bit of resolution would be feasible. To do that, I'm thinking of adding an alias field to our import definition which would record the import's scope-specific name (to handle the case in the description), and then emitting potentially consumed symbols for any consumed_symbols which are relative to (i.e., start-with) any in-scope import aliases. Thoughts @tdyas , @chrisjrn ?

Also, while it's been useful to have more data emitted as JSON to Python, it occurs to me that we could be doing ~all of the consumed symbols calculations inline in the parser (or at least, before emitting JSON).

@tdyas
Copy link
Contributor

tdyas commented Dec 1, 2021

Also, while it's been useful to have more data emitted as JSON to Python, it occurs to me that we could be doing ~all of the consumed symbols calculations inline in the parser (or at least, before emitting JSON).

That gets into partial type solving which is something that I had looked into a little but punted on as JavaParser’s existing code wants to completely type solve and it would’ve required a fair bit of work to try and do partial type solving. For Scala, I never got the chance to see what scalameta had for type solving. Definitely a path that we had considered earlier but could be a fair bit of work.

stuhood added a commit that referenced this issue Dec 2, 2021
Relative imports are common in Scala, and not supporting them caused ~12% of the issues in our test repository. See #13740 for background.

To support them, compares the final token of an import (or its alias, if it has one) to the first token of any multi-token symbol that is scoped below the import.

Fixes #13740.
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

Successfully merging a pull request may close this issue.

2 participants