-
Notifications
You must be signed in to change notification settings - Fork 10.6k
SR-3359: Add a fix-it to remove @discardableResult on functions returning Void or Never #6681
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
SR-3359: Add a fix-it to remove @discardableResult on functions returning Void or Never #6681
Conversation
|
@swift-ci Please smoke test |
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 spelling, here as elsewhere, should be @discardableResult (also, Void). Note also indentation and capitalization of this line (align quotation mark, lowercase f). I also wonder if the right message is "cannot be"--perhaps just "@discardableResult redundant for function returning Void"?
|
While you're at it, wouldn't it be wise to do the same for functions that return |
|
This looks great, Matthew! I agree with Xiaodi's comments here both on diagnostic phrasing and on supporting |
|
I wonder if this would be more appropriate as part of the |
|
Thanks @jrose-apple! Thanks for your comments @xwu. I'll make the changes you suggested. |
|
@CodaFi: Ah, IIRC |
|
…but it might make sense in the regular |
|
Jordan and Robert, I left the test for @discardableResult on functions returning Void or Never in Thanks! |
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.
Oops?
|
I think (I should beef up the doc comment to explain that.) |
…n functions that return Void or Never This commit adds a fix-it to remove @discardableResult on functions that return Void or Never. The fix-it is at the warning level. A test was added to verify that the fix-it removes the @discardableResult. This issue was reported in SR-3359: https://bugs.swift.org/browse/SR-3359 Changes: TypeCheckAttr.cpp: implemented AttributeChecker::visitDiscardableResultAttr to add a fix-it to remove @discardableResult on functions returning Void or Never. DiagnosticsSema.def: Added a warning with a diagnostic message. LoggingWrappers.swift.gyb, HashedCollections.swift.gyb: Removed @discardableResult on functions returning Void. fixits-apply-all.swift, fixits-apply-all.swift.result: Added tests to verify that @discardableResult is removed from functions returning Void or Never.
|
I moved the diagnostic into |
|
No other comments--looks good! |
|
Thanks, Matthew! |
This commit adds a fix-it to remove @discardableResult on functions that return Void. The fix-it is at the warning level. A test was added to verify that the fix-it removes the @discardableResult. This issue was reported in SR-3359:
https://bugs.swift.org/browse/SR-3359
Changes:
TypeCheckDecl.cpp: Added a test to add a fix-it for an @discardableResult declared on functions that return Void.
DiagnosticsSema.def: Added a warning with a diagnostic message.
LoggingWrappers.swift.gyb, HashedCollections.swift.gyb: Removed @discardableResult on functions that return Void.
fixits-apply-all.swift, fixits-apply-all.swift.result: Added a test to verify that @discardableResult is removed from a function that returns Void.