[CodeCompletion] Reuse CompletionContextFinder for fallback completion when no typeCheckExpression call is made #34287
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.
Also adjust the fallback context it choses now that
ErrorExprs no longer cause constraint generation to fail, and provide the correct DeclContext of the fallback as well, rather than using the DeclContext of the original expression.This PR also fixes some issues with the fallback logic in
typeCheckForCodeCompletion:For completion expressions in multi-statement closures, we were assuming a separate
typeCheckExpressioncall would be made when the outer expression produced a single solution that had a resolved type for the closure. If the solution contained other fixes unrelated to the closure however, it wasn't applied and a separate call for the body was never made.typeCheckForCodeCompletionsometimes falls through to normal expression type checking but didn't update the passed-in target's expression after sanitizing and prechecking it, which may have modified it and/or its sub-expressions. This triggered assertion failures in certain cases due to a stale top-level expression pointer being used with updated subexpressions.