-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AST] Improve ErrorType handling in TypeBase::getMemberSubstitutions() #272
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
This LGTM, but I think @DougGregor should also take a look when he gets a chance. Great work, thank you! -Chris |
Indeed it solves some issues, but the problem actually caused by this line:
The best way to fix those crashes, imho, would be to use safer API for casting:
otherwise some other non- |
@AlexDenisov thanks for the input. I would assume the Really makes me wish this were all written in Swift, so we could use optional chaining and |
Updated with new fixed crashers. |
@@ -2498,7 +2498,7 @@ TypeSubstitutionMap TypeBase::getMemberSubstitutions(DeclContext *dc) { | |||
|
|||
// Gather all of the substitutions for all levels of generic arguments. | |||
GenericParamList *curGenericParams = dc->getGenericParamsOfContext(); | |||
while (baseTy) { | |||
while (baseTy && !baseTy->is<ErrorType>()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather that the ErrorType check happen a little later, e.g., turn the "castAs()" into a "getAs()" within an "if". Then, we only check the ErrorType condition if all else fails, and can null out baseTy before breaking out of the loop.
15b222c
to
bdaf1de
Compare
@DougGregor: Updated. (Note that some tests are failing for other reasons; I fixed them in #296.) I have general questions about the error-handling mechanisms throughout; I sent an email to |
@DougGregor please let me know if there's anything else to be done here! |
Historical note: a similar change was made in 0033bda.
@@ -2517,7 +2517,17 @@ TypeSubstitutionMap TypeBase::getMemberSubstitutions(DeclContext *dc) { | |||
} | |||
|
|||
// Continue looking into the parent. | |||
baseTy = baseTy->castTo<NominalType>()->getParent(); | |||
auto nominalTy = baseTy->getAs<NominalType>(); | |||
if (!nominalTy || nominalTy->is<ErrorType>()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getAs will either produce a NominalType or null; there's no need to check for ErrorType here.
[AST] Improve ErrorType handling in TypeBase::getMemberSubstitutions()
Revert "Also xfail NonEmpty on swift-4.2-branch"
Historical note: a similar change was made in 0033bda.
Fixes 78 compiler_crashers. ⛵