[5.0][CodeCompletion] Rework getOperatorCompletions() #20785
Merged
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 of #20632 to
swft-5.0-branch
)In postfix completion, for operator completion, we do:
type to the root of the expression.
i. Build temporary binary/postfix expression
ii. Perform type checking to see whether the operator is applicable
This could be very slow especially if the operand is complex.
Introduce
ReusePrecheckedType
option to constraint system. Withthis option, CSGen respects pre-stored types in expressions and doesn't
take its sub-expressions into account.
generated for sub-expressions of LHS (45511835)
expression walkers in
CSGen
doesn't walk into the operand.Introduce
TypeChecker::findLHS()
to find LHS for a infix operator frompre-folded expression. We used to
foldSequence()
temporarySequenceExpr
and find 'CodeCompletionExpr' for each attempt.BinaryExpr
which used to be allocated byfoldSequence()
.foldSequence()
recovers invalidcombination of operators by
left
associative manner (withdiagnostics). This used to cause false-positive results. For instance,
a == b <HERE>
used to suggest==
operator.findLHS()
returnsnullptr
for such invalid combination.rdar://problem/43008573
rdar://problem/45511835
https://bugs.swift.org/browse/SR-9061