Skip to content

Fix invented names causing incorrect spans in semanticdb #11805

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

Merged
merged 1 commit into from
Mar 24, 2021
Merged

Fix invented names causing incorrect spans in semanticdb #11805

merged 1 commit into from
Mar 24, 2021

Conversation

Kordyjan
Copy link
Contributor

Fixes #11692.

Anonymous given instances and anonymous given aliases have their names invented during the desugaring. Those names are not treated as being synthetic neither they are present in sources. This results in incorrect spans being assigned to them, which is a problem for tools that are using semanticdb. This pr fixes that problem by comparing name spans with corresponding spans in sources. Other parts of the compiler can still call NamedDefTree#nameSpan and get an incorrect result.

I've tried to solve that problem without reading sources, by adding abstract def hasNamePresentInSource: Boolean to NamedDefTree, so it can be used in nameSpan method and fix this problem globally. It turned out that this method cannot be correctly implemented for DefDefs and some anonymous given aliases are desugared to defs, so this approach was not successful. If we really want to solve this problem globally we will need to add some attachment during desugaring.

@bishabosha
Copy link
Member

bishabosha commented Mar 23, 2021

There needs to be a rebase and the expect files need to be updated because of #11838

Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from needing the rebase

@Kordyjan Kordyjan enabled auto-merge March 24, 2021 09:07
@Kordyjan Kordyjan merged commit ad4853e into scala:master Mar 24, 2021
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Semanticdb] Anonymous given names are show in occurences
2 participants