Swift property with assigned value and didSet conflicting

Originator:s
Number:rdar://19078050 Date Originated:25/11/2014
Status:Open Resolved:
Product:Developer tools Product Version:
Classification:UI/Usability Reproducible:Always
 
Summary:
In swift, when you define a property, you can assign a value directly to it, making the compiler recognising the type and sets it for you. However, if you want to do things like "willSet" or "didSet" it'll fail, and you'll be forced to create an explicit type.

class SomeClass {
    // a will be recognised as a computed property, but it's not. It will therefore require you to assign an explicit type.
    var a = "hello, world" {
        didSet {

        }
    }
    
    // b won't fail, since it's explicit type is String
    var b: String = "hello, world" {
        didSet {
            
        }
    }
}

This is wrong, since none of them above are computed properties.

Steps to Reproduce:
Run the above code in a playground

Expected Results:
Both a and b will succeed to be a property of a String

Actual Results:
Both a and b will be computed properties and a will fail since it doesn't have an explicit type.

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!