-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Don't show enum completions in new keyword context #20304
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise lgtm
@@ -535,7 +532,7 @@ class Completions( | |||
val query = completionPos.query | |||
if completionMode.is(Mode.Scope) && query.nonEmpty then | |||
val visitor = new CompilerSearchVisitor(sym => | |||
if Completion.isValidCompletionSymbol(sym, completionMode) && | |||
if Completion.isValidCompletionSymbol(sym, completionMode, isNew) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like maybe it would be a bit more natural to pass untyped tree here instead of isNew
, since isNew
is always calculated via the same function and can be postponed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would compute it on every isValidSymbol
call, and it can be hundreds of calls, tho ? I did especially this way because we don't recompute this check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still duplication, as we're first filtering them in the compiler completions, and then again in Completions.scala from presentation compiler, but I think that this check is fast enough, that eliminating completions before searching for apply / constructors in withCompletionSuffix
is completely worth it.
Fixes #19968
Kudos to @aherlihy and @nmcb for solving this together during a spree. I hope you had fun :D