Skip to content

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

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 2, 2022

If the first type has a code completion token, don't record a same type constraint because otherwise if we have

  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 rintaro May 2, 2022 15:19
@ahoppen
Copy link
Member Author

ahoppen commented May 2, 2022

@swift-ci Please smoke test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

Comment on lines 364 to 365
FirstType.get(), PreviousLoc,
new (Context) ErrorTypeRepr(PreviousLoc)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't really matter, but I don't think we need to use fake locations.

Suggested change
FirstType.get(), PreviousLoc,
new (Context) ErrorTypeRepr(PreviousLoc)));
FirstType.get(), EqualLoc,
new (Context) ErrorTypeRepr(SecondType.getLoc())));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you’re right. That’s what I got from copy-pasting the fake requirement from below.

… 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 force-pushed the pr/complete-type-with-same-type-requirement branch from 72c66d2 to a35f185 Compare May 3, 2022 07:37
@ahoppen
Copy link
Member Author

ahoppen commented May 3, 2022

@swift-ci Please smoke test

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