What is the best option to provide a multiple-choice deprecation in Kotlin?
I'm trying to find the best way to provide a replacement for deprecated parameter.
Having a enum class A with a deprecated element X
enum class A {
@Derecated
X,
Y,
Z
}
I want IDE to suggest a quickfix replacement for X in my code.
To support it I can provide a replaceWith value. However, it's not possible to provide a multiple-choice option.
X could be replaced with Y or Z.
enum class A {
@Derecated(
message = "...",
replaceWith = ReplaceWith("Y or Z"),
DeprecationLevel.WARNING,
)
X,
Y,
Z
}
With ReplaceWith("Y or Z") IDE can suggest a quickfix, but it will break a compilation:
// works, but breaks compilation
A.X -> A.Y or Z