Skip to content

[Typechecker] Emit specialized diagnostic notes on automatic synthesis failure to Comparable #32797

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
Jul 14, 2020

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Jul 9, 2020

Automatic synthesis of Comparable is only supported for enums for now. So, if we have a struct or a class and a conformance failure to Comparable, emit a note just like we do for Equatable (on classes) for example, to let the user know that automatic synthesis is unsupported.

As a bonus, also emit a note when the enum has a raw type or if the associated values don't conform to Comparable.

Resolves SR-13148
rdar://problem/65116465

@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

@theblixguy theblixguy changed the title [Typechecker] Emit a note on conformance failure to Comparable about automatic synthesis [Typechecker] Emit specialized diagnostic notes on automatic synthesis failure to Comparable Jul 10, 2020
@theblixguy
Copy link
Collaborator Author

theblixguy commented Jul 10, 2020

The last commit is NFC - I did some refactoring as I wanted to reuse some code for the notes and avoid a lot of duplication.

There’s a bit more I need to refactor, I think I will probably put this commit and the new one into a separate PR instead.

@swift-ci please smoke test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

LGTM! But please revert all of the formatting changes to the unrelated parts of code before merging.

@theblixguy
Copy link
Collaborator Author

Sorry about that. I am actually gonna create a separate PR for the refactoring, so I am gonna revert that commit for now.

@swift-ci please smoke test

@xedin
Copy link
Contributor

xedin commented Jul 11, 2020

Sounds good!

@xedin
Copy link
Contributor

xedin commented Jul 11, 2020

@theblixguy Could you do me a favor and wait until #32828 lands? I have moved en.yaml to diagnostics/ instead of include/swift/AST/diagnostics...

@theblixguy
Copy link
Collaborator Author

Sure no worries!

@xedin
Copy link
Contributor

xedin commented Jul 11, 2020

Thank you!

@xedin
Copy link
Contributor

xedin commented Jul 14, 2020

@theblixguy Localization changes went in so you can rebase and merge this PR, thank you for waiting!

@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

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.

5 participants