[5.7][LookupVisibleDecls] Implement shadowing for unqualified lookups #58530
+506
−76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick #58512 into
release/5.7
lookupVisibleDecls()
function used by code completion is supposed to return all visible and usable declarations. It used to have several issues, such as local types/funcs declared after the code completion point weren't reported despite they are usable, unusable instance members in outer type context were reported, unusable local values outside the current type context were reported, and the name shadowing wasn't implemented. Especially, the lack of shadowing results duplicated code completion entries, for example, inif let user = user { <HERE> }
, both the outeruser: User?
and the inneruser: User
were reported, which was confusing. This change resolves those issues, so that code completion can provide more accurate results.primary-expression
andtype-identifier
)