-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] Add InFlightDiagnostic::warnUntilSwiftVersion
to downgrade errors to warnings
#38302
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
diagnostic behavior to a warning until the specified language version. This helper can be used to stage in fixes for stricter diagnostics as warnings until the next major language version.
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.
Great improvement!
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.
This is great, thank you!
@@ -44,6 +44,10 @@ NOTE(previous_decldef,none, | |||
NOTE(brace_stmt_suggest_do,none, | |||
"did you mean to use a 'do' statement?", ()) | |||
|
|||
WARNING(error_in_future_swift_version,none, | |||
"%0; this will be an error in Swift %1", | |||
(DiagnosticInfo *, unsigned)) |
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 diagnostic wrapping approach here is very cool. The "will be" wording feels a little off for existing warnings, because "will be an error in Swift 5" should really be "is an error in Swift 5". Should we say "is an error in Swift 5" instead?
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.
Good point. As soon as you use warnUntilSwiftVersion
, that diagnostic is already an error under that language version. I'll update the wording to your suggestion 👍
WARNING(ownership_invalid_in_protocols_compat_warning,none, | ||
"%0 should not be applied to a property declaration " | ||
"in a protocol and will be disallowed in future versions", | ||
(ReferenceOwnership)) |
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.
Good find. I have so many places I'd like to use this!
warnUntilSwiftVersion, specify when the diagnostic will become an error in the message.
…protocols diagnostic and remove ownership_invalid_in_protocols_compat_warning.
4713e0d
to
b9040c7
Compare
@swift-ci please smoke test |
@swift-ci please test Linux platform |
@swift-ci please smoke test Linux platform |
@swift-ci please test Windows platform |
1 similar comment
@swift-ci please test Windows platform |
warnUntilSwiftVersion
limits the diagnostic behavior to a warning until the specified language version. This helper can be used to stage in fixes for stricter diagnostics as warnings until the next major language version.