"Ambiguous use of 'propertyName'" error given overridden property with didSet observer

I was able to work around this in my case by casting to the base class:

(employee as Person).name = "Sally"

This still appears to do the proper dispatch to the subclass. For instance:

class Person {
    var name: String {
            return "person"
    }
}

class Employee: Person {
    override var name: String {
        return "employee"
    }
}

let bob = Person()
let alice = Employee()

println((alice as Person).name) // prints "employee"

As @sgaw points out, this has been confirmed as a known bug by the Apple engineers (for Xcode 6 Beta - Version 6.0 (6A215l))

https://devforums.apple.com/thread/229668?tstart=0


I got this error because I had two properties declared with the same name.

On Objective-C the compiler used to give the error on the line the property was declared. Something like "duplicate property".

Now on Swift you get "Ambiguous use of..." on the line that you use to property... and you have to look everywhere to find the duplicate property.

Tags:

Swift