Skip to content

[CodeCompletion] Ensure all ExtensionDecl's extended types are computed #33669

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
Aug 28, 2020

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Aug 27, 2020

Fixes an assertion failure in ASTScope lookup

rdar://problem/67102794

@rintaro
Copy link
Member Author

rintaro commented Aug 27, 2020

@swift-ci Please smoke test

extensions.back()->computeExtendedNominal();
extensions.pop_back();
}
class ExtensionBinder: public ASTWalker {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this traverse the AST instead of iterating over the top level declarations in a file or something?

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 thought we need to handle something like:

struct Something {

extension A: B.#^HERE^# {
}

But I didn't know this already has ErrorType as the extended type.
Will fix it.

Copy link
Member Author

Choose a reason for hiding this comment

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

this already has ErrorType as the extended type.

Well, this is not true. But somehow

struct Something {

extension A: B.#^HERE^# {
}

doesn't crash. I will investigate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Malformed ASTs makes sense. Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I see. Non-toplevel extension is canNeverBeBound(). So we don't need to compute the extended nominal unless it's top-level.

…uted

Fixes an assertion failure in ASTScope lookup

rdar://problem/67102794
@rintaro rintaro force-pushed the ide-completion-rdar67102794 branch from a3989ef to e013ebd Compare August 27, 2020 23:18
@@ -46,9 +46,11 @@ void swift::ide::typeCheckContextAt(DeclContext *DC, SourceLoc Loc) {
while (isa<AbstractClosureExpr>(DC))
DC = DC->getParent();

// Make sure the extension has been bound, in case it is in an inactive #if
// or something weird like that.
Copy link
Member Author

Choose a reason for hiding this comment

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

Code completion never happens inside inactive #if since #33475

@rintaro
Copy link
Member Author

rintaro commented Aug 27, 2020

@swift-ci Please smoke test

@rintaro rintaro requested a review from nathawes August 28, 2020 00:29
Copy link
Contributor

@nathawes nathawes left a comment

Choose a reason for hiding this comment

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

LGTM!

@rintaro rintaro merged commit f3cebd2 into swiftlang:master Aug 28, 2020
@rintaro rintaro deleted the ide-completion-rdar67102794 branch October 16, 2020 23:26
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