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

Fix bug around resetting presentation compilers. #1590

Merged
merged 1 commit into from Apr 8, 2020

Conversation

olafurpg
Copy link
Member

@olafurpg olafurpg commented Apr 8, 2020

Previously, Metals didn't correctly reset all presentation compiler
after a successful compilation. Users could observe this bug when
completions don't return symbols from other files that have been
recently changed.

Now, Metals resets all presentation compilers that may be affected by a
successful compile notification making it less likely that
completions/hover/signatureHelp return stale results.

This root cause of this bug was discovered in #1523 by Tomasz. The
problem was that Metals only collected the leaf build targets that
depend on the compiled target. Now, we reset all inverse dependencies
regardless if they're leaf targets or not.

Previously, Metals didn't correctly reset all presentation compiler
after a successful compilation. Users could observe this bug when
completions don't return symbols from other files that have been
recently changed.

Now, Metals resets all presentation compilers that may be affected by a
successful compile notification making it less likely that
completions/hover/signatureHelp return stale results.

This root cause of this bug was discovered in scalameta#1523 by Tomasz. The
problem was that Metals only collected the leaf build targets that
depend on the compiled target. Now, we reset all inverse dependencies
regardless if they're leaf targets or not.
@olafurpg olafurpg requested a review from tgodzik April 8, 2020 12:55
@olafurpg
Copy link
Member Author

olafurpg commented Apr 8, 2020

Kudos to @tgodzik for tracking down the root cause of this bug. I have observed this bug for a long time but didn't know how to reliably reproduce it or fix it.

"package a; object A"
)
_ = assertNoDiagnostics()
_ = assertEquals(0, server.server.loadedPresentationCompilerCount())
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we try to change both files to contain new names and assert that both new names are picked up from another file after only compiling a?

I think that would test the same thing and not require the additional loadedPresentationCompilerCount

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with the principle that we should reproduce the user-facing situation instead of testing against implementation details. My concern with reproducing the exact scenario is that we'll end up with a flaky test.

It's critical that we reset the presentation compiler for getting good user experience and I think it will be helpful in the future to have isLoaded() as a toolkit to test related fixes.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the PR!

@tgodzik tgodzik merged commit f97f1ab into scalameta:master Apr 8, 2020
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 this pull request may close these issues.

None yet

2 participants