Is there a way to mark something with `@Deprecated...
# announcements
z
Is there a way to mark something with
@Deprecated(level = ERROR, ...)
, or even
HIDDEN
, but still use it in my own code somehow? Seems like I can only suppress the
WARNING
level of deprecation.
t
If it's only intended to be used in your own code, you could make the declaration
internal
, so that only your module can access it, and mark it as
Deprecated(level = WARNING)
so you remember that it shouldn't be used. Even better, you could mark the public declaration as Deprecated (any level you want), and move its implementation to a private declaration that you use from your code.
z
Thanks for the tips! I did try the private implementation approach, but then I ended up with just having it as
internal
. The tricky part is that I actually need to use it from another module (of the same library, so this is also sort of internal usage), so now I have a single Java file in that other module with a helper that calls this
internal
API, since Java code can call into internal declerations... 😅
Oh, and I threw in
@JvmName
so that the name of the function doesn't get mangled, and can be called reliably.
d
I believe you can suppress the deprecation error.
z
I found that supress only worked for the
WARNING
level, and not the stronger ones.