[swift-evolution] Pitch: Omit deprecation warnings for same-file references

Tony Arnold tony at thecocoabots.com
Fri May 5 17:20:36 CDT 2017


Hi Tony,

> On 6 May 2017, at 04:12, Tony Allevato via swift-evolution <swift-evolution at swift.org> wrote:
> 
> These warnings are emitted for any reference to a deprecated entity, including those in the same file. In some cases, however, it may be necessary and correct to continue referring to the deprecated entity privately while discouraging its external use. In these scenarios, the warnings are superfluous and generate noise in the build logs. We propose eliminating these warnings for references made in the same file.

If same file is the direction that the proposal is leaning toward, what’s stopping you from creating an internal (or private) implementation that’s not deprecated. You could then call that via the public, deprecated method/property?

i.e.

```swift
@available(*, deprecated, message: "use 'phoneNumbers' instead")
public var phoneNumber: String? {
    get {
        return _phoneNumber
    }
    set {
        _phoneNumber = newValue
    }
}

private var _phoneNumber: String?

```

Am I missing something that would prevent this from working?

I can see that what you’re proposing would negate the need for the private backing property/method, but it seems like it’s introducing complexity for the few times you might need this.

thanks,


Tony



----------
Tony Arnold
+61 411 268 532
http://thecocoabots.com/

ABN: 14831833541



More information about the swift-evolution mailing list