Skip to content

[5.5][CodeCompletion] Migrate key path completion to be solver based #38178

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

Merged
merged 1 commit into from
Jul 1, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 30, 2021

  • Explanation: This migrates code completion inside key paths to the new solver-based implementation, using the solutions discovered by the type checker to infer the base on which to complete the next key path component. This fixes issues where code completion wasn’t working in key paths that had a generic base or result (which I believe is a very common case).
  • Scope: Code completion inside key paths
  • Risk: Low to medium (this is a fundamental change to how code completion inside key paths works but I feel confident that it’s correct since it’s using the same approach that we use for member completion)
  • Testing: Added regression tests
  • Issue: rdar://78779234 and rdar://78779335
  • Reviewer: @xedin (Pavel Yaskevich) on original PR [CodeCompletion] Migrate key path completion to be solver based #38049

This commit essentially consistes of the following steps:
- Add a new code completion key path component that represents the code completion token inside a key path. Previously, the key path would have an invalid component at the end if it contained a code completion token.
- When type checking the key path, model the code completion token’s result type by a new type variable that is unrelated to the previous components (because the code completion token might resolve to anything).
- Since the code completion token is now properly modelled in the constraint system, we can use the solver based code completion implementation and inspect any solution determined by the constraint solver. The base type for code completion is now the result type of the key path component that preceeds the code completion component.

This resolves bugs where code completion was not working correctly if the key path’s type had a generic base or result type. It’s also nice to have moved another completion type over to the solver-based implementation.

Resolves rdar://78779234 [SR-14685] and rdar://78779335 [SR-14703]
@ahoppen ahoppen added the r5.5 label Jun 30, 2021
@ahoppen ahoppen requested a review from akyrtzi June 30, 2021 20:14
@ahoppen ahoppen requested a review from a team as a code owner June 30, 2021 20:14
@ahoppen
Copy link
Member Author

ahoppen commented Jun 30, 2021

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jul 1, 2021

Windows failure is unrelated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants