Skip to content

[5.7][CodeCompletion] Offer suggestions if a nested type is followed by a same type requirement #58657

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 4, 2022

Cherry-pick #58614 to release/5.7.


  • Explanation: When completing a type inside a where clause that already had a type on the right-hand side of a == requirement, e.g. K.#^COMPLETE^# == Foo, we weren’t providing any results because we parsed it as K == Foo and thus were providing completion on Foo instead of the more generic type K. Drop the == Foo requirement in these code completion cases to avoid the issue.
  • Scope: Code completion in where clauses that have a == <some-type> requirement after the code completion token.
  • Risk: Low (only affects code completion)
  • Testing: Added regression test case
  • Issue: rdar://77458518
  • Reviewer: @rintaro on [CodeCompletion] Offer suggestions if a nested type is followed by a same type requirement #58614

… equal type requirement

If the first type has a code completion token, don't record a same type constraint because otherwise if we have
```swift
  K.#^COMPLETE^# == Foo
```
we parse this as
```
  K == Foo
```
and thus simplify `K` to `Foo`. But we didn't want to state that `K` is `Foo` but that `K` has a member of type `Foo`.

rdar://77458518
@ahoppen ahoppen requested a review from a team as a code owner May 4, 2022 06:53
@ahoppen ahoppen changed the title [5.7[CodeCompletion] Offer suggestions if a nested type is followed by a same type requirement [5.7][CodeCompletion] Offer suggestions if a nested type is followed by a same type requirement May 4, 2022
@ahoppen
Copy link
Member Author

ahoppen commented May 4, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit c5fbb48 into swiftlang:release/5.7 May 6, 2022
@ahoppen ahoppen deleted the pr-5.7/complete-type-with-same-type-requirement branch May 6, 2022 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants