Is it possible to deprecate a function only for Kotlin? Imagine that I have a function in Java
public static boolean isEmpty(@Nullable CharSequence str) {
return str == null || str.length() == 0;
}
And I would like to deprecate it for Kotlin users. I can change it to use an stdlib function
@JvmStatic
@Deprecated("Use `isNullOrEmpty`", replaceWith = ReplaceWith("str.isNullOrEmpty()"))
fun isEmpty(str: CharSequence?): Boolean = str.isNullOrEmpty()
and it will warn Kotlin users and guide them towards the stdlib function, however it will also show as
@deprecated
for Java, where it is still needed (
isNullOrEmpty
is
InlineOnly
). Is it possible to show as deprecated only for Kotlin?