Skip to content
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

[CodeCompletion] Suggest typealias on protocols #38054

Merged
merged 1 commit into from Jul 2, 2021

Conversation

ahoppen
Copy link
Contributor

@ahoppen ahoppen commented Jun 23, 2021

Previously, we were never suggesting typealias declarations when completing on a protocol type.

Fixes rdar://78780638 [SR-14688]

@ahoppen ahoppen requested a review from rintaro June 23, 2021 16:44
@ahoppen
Copy link
Contributor Author

ahoppen commented Jun 23, 2021

@swift-ci Please smoke test

@@ -156,6 +156,12 @@ static bool isMemberDeclAppliedInternal(const DeclContext *DC, Type BaseTy,
GenericSignature genericSig = genericDecl->getGenericSignature();
if (!genericSig)
return true;
if (isa<TypeAliasDecl>(VD) && BaseTy->is<ProtocolType>()) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we do this before line 153, before getting the generic signature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, makes sense as it’s cheaper to check. Moved it up

// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t

protocol MyProto {
typealias Content = Int
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a typealias with generic arguments? e.g. typealias Storage<T> = Array<T>. I don't this your change affects this case, but still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test case. Seems to not be an issue.

Previously, we were never suggesting typealias declarations when completing on a protocol type.

Fixes rdar://78780638 [SR-14688]
@ahoppen ahoppen force-pushed the pr/suggest-typealias-on-protocols branch from 3a17aba to 088a331 Compare July 1, 2021 14:29
@ahoppen
Copy link
Contributor Author

ahoppen commented Jul 1, 2021

@swift-ci Please smoke test

@ahoppen
Copy link
Contributor Author

ahoppen commented Jul 2, 2021

Windows failures is unrelated.

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.

None yet

2 participants