-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CodeCompletion] Workaround fast-completion issue in UnqualifiedLookup #29763
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
[CodeCompletion] Workaround fast-completion issue in UnqualifiedLookup #29763
Conversation
@swift-ci Please smoke test |
@davidungar Based on our offline conversation, I just added a workaround code that only kicks in code completions. |
lib/AST/UnqualifiedLookup.cpp
Outdated
// happen from the 'loc' that is in a different buffer from the 'decl'. | ||
// In such cases, look for members because we know 'loc' is inside a | ||
// function body in the 'decl'. | ||
if (SM.getCodeCompletionBufferID() != 0U) { |
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'd suggest a convenience API hasCodeCompletionBuffer()
so that the caller doesn't have to remember what return value to check for.
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.
That's a great suggestion! I second it.
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.
Thanks for sticking with this! I think that this fix will be much better for future maintainers (including me!) to deal with.
lib/AST/UnqualifiedLookup.cpp
Outdated
|
||
// If a code completion happens inside a function body, some lookups may | ||
// happen from the 'loc' that is in a different buffer from the 'decl'. | ||
// In such cases, look for members because we know 'loc' is inside a |
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.
This comment would be slightly clearer to me by added the words "of the 'decl'" after "look for members".
In other words: "In such cases, look for members of the 'decl' because we know 'loc' is inside a function body in the 'decl'."
lib/AST/UnqualifiedLookup.cpp
Outdated
// happen from the 'loc' that is in a different buffer from the 'decl'. | ||
// In such cases, look for members because we know 'loc' is inside a | ||
// function body in the 'decl'. | ||
if (SM.getCodeCompletionBufferID() != 0U) { |
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.
That's a great suggestion! I second it.
In fast-completion, a function body can be replaced with another function body parsed from a new buffer. In such cases, during typechecking the expressions in the *new* function body, a source location range check in UnqualifiedLookup didn't work well because they are not from the same buffer. This patch workaround it by skipping the source range checks and returns 'success' in such cases. rdar://problem/58881999
72e1aba
to
ff2ccd4
Compare
@swift-ci Please smoke test |
In fast-completion, a function body can be replaced with another function body parsed from a new buffer. In such cases, during typechecking the expressions in the new function body, a source location range check in UnqualifiedLookup didn't work well because they are not from the same
buffer.
This patch workaround it by skipping the source range checks and returns 'success' in such cases.
rdar://problem/58881999