Files
swift-mirror/test/FixCode/fixits-apply-all.swift
Matthew Carroll 0e09bbbb83 [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.
2017-01-11 15:12:36 -08:00

27 lines
663 B
Swift

// This tests whether we accept fixits from warnings without filtering.
// The particular diagnostics used are not important.
// RUN: %swift -typecheck -target %target-triple %s -fixit-all -emit-fixits-path %t.remap
// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
func ftest1() {
let myvar = 0
}
func foo() -> Int {
do {
} catch var err {
goo(err)
}
}
func goo(_ e: Error) {
}
@warn_unused_result(message="test message")
func warn_unused_result_removal() -> Int { return 5 }
@discardableResult func discardableResultOnVoidFunc() {}
@discardableResult func discardableResultOnNeverFunc() -> Never { fatalError() }