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

[ASTPrinter] Account for contextual where clauses when printing gen. … #30488

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

AnthonyLatsis
Copy link
Collaborator

@AnthonyLatsis AnthonyLatsis commented Mar 18, 2020

…requirements

follow-up on #23489

@AnthonyLatsis AnthonyLatsis requested a review from CodaFi March 19, 2020 21:14
@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test

1 similar comment
@theblixguy
Copy link
Collaborator

@swift-ci please smoke test

@AnthonyLatsis AnthonyLatsis requested review from slavapestov and removed request for CodaFi March 21, 2020 04:36
@AnthonyLatsis AnthonyLatsis force-pushed the ast-printer-se-0267 branch 2 times, most recently from df5e21d to 7ce9135 Compare March 24, 2020 19:31
@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test

@AnthonyLatsis
Copy link
Collaborator Author

@slavapestov Do you have a minute to sanity check this (the change is almost trivial)? Thank you.

void PrintAST::printDeclGenericRequirements(GenericContext *decl) {
// Even if the declaration is not generic, it might carry a contextual
// where clause.
if (!decl->isGeneric() && !decl->getTrailingWhereClause())
Copy link
Contributor

@slavapestov slavapestov Mar 25, 2020

Choose a reason for hiding this comment

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

It might be more robust to just check that the decl's generic signature is different (pointer-wise) than the parent context's as a fast path, and then do the loop over the unstatisfied requirements. Otherwise, it's possible that the precondition goes out of sync (but unlikely, I guess)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, the where clause is always around no matter how the generic signature computation went. Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

While this is safer, perhaps it makes sense to also get rid of completely invalid where clauses on non-generic top-level declarations when we diagnose them, since we won't ever need to inspect them anyways?

@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test

@AnthonyLatsis AnthonyLatsis merged commit 3b3eade into swiftlang:master Mar 26, 2020
@AnthonyLatsis AnthonyLatsis deleted the ast-printer-se-0267 branch February 3, 2021 05:35
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