Skip to content

[CodeCompletion] Calculate type relation when adding type annotation #33978

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 2 commits into from
Sep 17, 2020

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Sep 17, 2020

Calculate and set the type relation in each result building logic which knows the actual result type.

CodeCompletionResultBuilder couldn't know the actual result type. From the declaration alone, it cannot know the correct result type because it doesn't know how the declaration is used (e.g. calling? referencing by compound name? curried?)

(#33749 (comment))

Calculate and set the type relation in each result building logic which
knows the actual result type.

CodeCompletionResultBuilder couldn't know the actual result type. From
the declaration alone, it cannot know the correct result type because it
doesn't know how the declaration is used (e.g. calling? referencing by
compound name? curried?)
@rintaro
Copy link
Member Author

rintaro commented Sep 17, 2020

@swift-ci Please smoke test

Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

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

Nice!

@@ -2490,7 +2430,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
}
}

return eraseArchetypes(T, GenericSig);
return T;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious: how did you ensure that every place that needs to eraseArchetypes in addTypeAnnotation has the correct generic signature passed in, especially since the generic signature is optional for that method? Did you make it non-optional and check every call, or was there some other approach?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just checked all usages of getTypeOfMember() and passed DC->getGenericSignatureOfContext() to type printing functions (addCallArgumentPatterns() and addTypeAnnotation()).

@rintaro rintaro merged commit d669247 into swiftlang:master Sep 17, 2020
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.

3 participants