Without using @objc @optional, is there a way to properly deprecate a function in a protocol? I cannot make use of the Objective-C runtime because I tend to have struct types conforming to this protocol.
Trivialized example:
protocol P {
@available(*, deprecated: 1.0.1, renamed: "g")
func f(x: Int)
func g(x: Int, y: String)
}
struct S: P { // Complains that "Type 'S' does not conform to Protocol 'P'"
func g(x: Int, y: String) {
}
}
Obviously, I could just remove the method, however, I'd like to notify the user that the method was renamed and allow the compiler to offer a fix.
No, but the fact that you've added a new requirement to the protocol is going to do that as well, since they'll suddenly get an error about a new requirement, which they'll have to lookup.
I believe it would be an IDE feature to warn users they're implementing a deprecated method. I'm not sure if that deserves its own language feature. I believe Xcode already shows such methods as being crossed out.
Right, they'll be able to get the new requirement, but they won't no the other one was deprecated and renamed to to this new one without looking at the method definition.
My hope is that it would be a feature of the compiler or IDE to error+correct the user like it does for classes and structs.