Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempting to store to property '' within its own willSet

Im getting a weird warning in the editor which I need help understanding what it wants

Attempting to store to property 'someProperty' within its own willSet, which is about to be overwritten by the new value

var someProperty:SomeClass! {
    willSet { someProperty?.someFunction() } // Get warning: Attempting to store to property 'someProperty' within its own willSet, which is about to be overwritten by the new value
    didSet { ... }
}

When I run it it is doing what I want it to do with no crashes or warnings in console, so I see this as just a false positive. So can I suppress it in any way because its annoying? :(

like image 234
Arbitur Avatar asked Mar 30 '15 10:03

Arbitur


1 Answers

This is a known bug, reported in the Apple Developer Forum: https://devforums.apple.com/message/1065306#1065306, with the workaround of adding an explicit self:

    willSet {
        self.someProperty?.someFunction()
    }

Update: I could not reproduce the issue with Xcode 7.3.1 or Xcode 8 anymore, so that seems to be fixed now.

like image 75
Martin R Avatar answered Nov 16 '22 02:11

Martin R