Open
Description
Previous ID | SR-2849 |
Radar | rdar://problem/31844597 |
Original Reporter | Alex (JIRA User) |
Type | New Feature |
Status | In Progress |
Resolution |
Additional Detail from JIRA
Votes | 8 |
Component/s | Compiler |
Labels | New Feature |
Assignee | @theblixguy |
Priority | Medium |
md5: a0372c6b5db167e925ad73f87d7f903e
is duplicated by:
- SR-6393 Warn on unused arguments
Issue Description:
When _ GCC_WARN_UNUSED_PARAMETER_
is enabled unused parameters does not produce warning.
How to reproduce:
- Set Yes to Build Settings/Apple LLVM 8.0 Warnings - All languages/Unused Parameters
- Add methods or blocks with unused parameters e.g.
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// There is usually no need to use `tableView` or `section` parameters for simple tables
return dataSource.count
}
or
NotificationCenter.default.addObserver(forName: .UIApplicationWillTerminate, object: nil, queue: nil) { notification in
// Prepare for app termination
}
Result:
No warnings.
Expected Result:
Xcode should warn about unused parameters: tableView
, section
and notification
.
Also Xcode should suggest to replace these parameters with _
which is already possible to do:
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
return dataSource.count
}
NotificationCenter.default.addObserver(forName: .UIApplicationWillTerminate, object: nil, queue: nil) { _ in
// Prepare for app termination
}
This setting works as expected in Objective-C (requires __unused
attribute to suppress the warning).