[Sema] Fix two assertion failures/crashes in solver-based key-path completion #38299
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.
This fixes two assertion failures/crashes in the solver-based key path completion I introduced in #38049, which were found by the stress tester.
Record type of identity key paths in the constraint system
If we are completing e.g.
\.self.#^COMPLETE^#
we use the type ofself
as the base type for the completion. In order to retrieve that, we need to record the type.Fixes rdar://80271346 [SR-14887]
Check completion key path component to determine if completion node was type checked in multi expression closure
To check whether the code completion node was type checked in a multi statement closure, we were assuming that we had a code completion expression and not considering that we could also complete in a key path component. When applicable, check if the completion key path component has a type to determine if the completion node was type checked as part of a multi-statement closure.
Resolves rdar://80271598 [SR-14891]