Skip to content

Sema: Improve diagnostics for overrides of unavailable decls #65456

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

Conversation

tshortli
Copy link
Contributor

Unavailable decls cannot be overridden by available decls. This change improves the compiler diagnostics for this restriction in a few ways:

  • Duplicate diagnostics are suppressed for getters and setters inside property declarations that have already been diagnosed.
  • Diagnostics are suppressed for implicit accessors since they would typically duplicate diagnostics for the explicit accessors the implicit ones are derived from.
  • Decls inside unavailable a derived class are no longer incorrectly diagnosed.

Unavailable decls cannot be overridden by available decls. This change improves
the compiler diagnostics for this restriction in a few ways:

- Duplicate diagnostics are suppressed for getters and setters inside property
  declarations that have already been diagnosed.
- Diagnostics are suppressed for implicit accessors since they would typically
  duplicate diagnostics for the explicit accessors the implicit ones are
  derived from.
- Decls inside unavailable a derived class are no longer incorrectly diagnosed.
@tshortli
Copy link
Contributor Author

@swift-ci please test

Comment on lines +2115 to +2117
auto unavailabilityStatusAndAttr =
checkOverrideUnavailability(override, base);
auto *unavailableAttr = unavailabilityStatusAndAttr.second;
Copy link
Contributor

@LucianoPAlmeida LucianoPAlmeida Apr 27, 2023

Choose a reason for hiding this comment

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

Nit: If we are in c++ 17 maybe we could use structured binding here =]

Suggested change
auto unavailabilityStatusAndAttr =
checkOverrideUnavailability(override, base);
auto *unavailableAttr = unavailabilityStatusAndAttr.second;
auto [status, unavailableAttr] =
checkOverrideUnavailability(override, base);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does seem nicer. I'm not going to revise this solely for that right now but I'll keep an eye out for opportunities to improve readability with this syntax in the future now that the project uses C++17.

@tshortli tshortli merged commit af05904 into swiftlang:main Apr 27, 2023
@tshortli tshortli deleted the improve-override-of-unavailable-diagnostics branch April 27, 2023 21:45
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.

2 participants