Swift: provide warning for shadowed names

Originator:chris
Number:rdar://20240784 Date Originated:20-Mar-2015
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6.2
Classification:UI/Usability Reproducible:Always
 
GCC/Clang provides a warning for shadowed variables (detailed below), but there is no equivalent in Swift. This is important in Swift since class-level variables, methods and the like may be used without a "self." prefix.

Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed.  [GCC_WARN_SHADOW, -Wshadow]

Steps to repro:

Declare a local variable in a method with the same name as a property of the class.

Expected: 

Swift should optionally provide a warning about the shadowed name.

Actual:

The compiler emits no warning about the shadowed name.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!