Seemingly-bogus error message when overriding a var

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Seemingly-bogus error message when overriding a var

Jens Alfke
I’ve got a variable with a public getter and internal setter, and I override it in a subclass but get an error complaining about the accessibility of the setter. This doesn’t make sense because the access control in the override is identical. If I take out “internal (set)”, to make the setter public, the error goes away; but I don’t want the setter to be public. What’s going on here?

(Xcode 7 beta 3)

public class Peer : NSObject {
    public internal(set) dynamic var online = false
}

public class OnlinePeer : Peer, NSNetServiceDelegate {
    public internal(set) override dynamic var online: Bool { … }
}

The error is:

Peer.swift:52:47: error: setter of overriding var must be as accessible as the declaration it overrides
    public internal(set) override dynamic var online: Bool
           ~~~~~~~~~~~~~~                     ^

           

Peer.swift:32:38: note: overridden declaration is here
    public internal(set) dynamic var online = false

—Jens

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/B486EC64-7220-4ABF-B98B-206F9E2A1D88%40mooseyard.com.
For more options, visit https://groups.google.com/d/optout.