[DiagnosticsQoI] SR-3359: Add a fix-it to remove @discardableResult on functions that return Void or Never (#6681)

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.
This commit is contained in:
Matthew Carroll
2017-01-11 18:12:36 -05:00
committed by Jordan Rose
parent f462ce7852
commit 0e09bbbb83
6 changed files with 32 additions and 3 deletions

View File

@@ -243,7 +243,6 @@ internal protocol _HashBuffer {
@discardableResult
mutating func removeValue(forKey key: Key) -> Value?
@discardableResult
mutating func removeAll(keepingCapacity keepCapacity: Bool)
var count: Int { get }