Skip to content

[AST] Handle getSuperclassForDecl() returning an ErrorType in more places #26750

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

nathawes
Copy link
Contributor

@nathawes nathawes commented Aug 20, 2019

We already were at some call sites, but weren't in ModuleDecl::lookupConformance() or TypeBase::getContextSubstitutions(). Code completion was hitting both of these cases.

Slava fixed the root cause of this in #26776. This is now just adding a regression test.

Resolves rdar://problem/54145042

@nathawes
Copy link
Contributor Author

@swift-ci please test

@slavapestov
Copy link
Contributor

Instead of fixing every call site, I think its better to address the root cause, which is that getSuperclass() returns an empty type if the substitution fails. It should use SubstFlags::UseErrorType instead. Try this change: 70b5342

@nathawes nathawes force-pushed the r54145042-code-completion-crash-differenceAndStoreConditionalRequirements branch from f82cccb to b3b3e07 Compare August 21, 2019 19:01
@nathawes
Copy link
Contributor Author

nathawes commented Aug 21, 2019

Thanks @slavapestov! Adding the flag worked. I had to change the helper a little from what was in your patch to maintain the existing behavior of getSuperclass(). Does this look ok now? Should I try removing the other checks for ErrorType?

@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes nathawes requested a review from slavapestov August 21, 2019 19:04
@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f82cccb0903bdc7969336f7810c0b3ce31c86a0f

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f82cccb0903bdc7969336f7810c0b3ce31c86a0f

@nathawes nathawes marked this pull request as ready for review August 21, 2019 20:11
@slavapestov
Copy link
Contributor

@nathawes I went ahead and changed Type::subst() so that it always returns a non-null Type, eliminating SubstFlags::UseErrorType in the process: #26776

Your new test case should pass with no further changes once my PR lands.

@nathawes nathawes force-pushed the r54145042-code-completion-crash-differenceAndStoreConditionalRequirements branch from b3b3e07 to 7dda615 Compare August 23, 2019 01:13
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - b3b3e07f66e7e884e0e5d628dcb4f862ecdf6412

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - b3b3e07f66e7e884e0e5d628dcb4f862ecdf6412

@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes nathawes force-pushed the r54145042-code-completion-crash-differenceAndStoreConditionalRequirements branch from 7dda615 to b073e98 Compare August 23, 2019 17:58
@nathawes
Copy link
Contributor Author

@swift-ci please smoke test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 7dda61544a1d85aaea6837847d05d54d673bd45d

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7dda61544a1d85aaea6837847d05d54d673bd45d

@nathawes nathawes merged commit bf82884 into swiftlang:master Aug 23, 2019
@nathawes nathawes deleted the r54145042-code-completion-crash-differenceAndStoreConditionalRequirements branch August 23, 2019 21:23
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