https://kotlinlang.org logo
f

Fleshgrinder

02/07/2020, 4:46 PM
So we have
@JvmSynthetic
to hide Kotlin functions from Java users, however, we have no equivalent
@JvmOnly
(or whatever it would be named) to hide definitions from Kotlin. I tried
@Deprecated("Java only", level = HIDDEN)
but it's hidden in Java afterwards as well if you use IntelliJ. 😛 Any known workarounds for this or is a feature request the only possible thing?
f

Fleshgrinder

02/07/2020, 4:50 PM
❤️
🤣
Copy code
@Suppress("ILLEGAL_KOTLIN_VERSION_STRING_VALUE")
@SinceKotlin("Java only")
Seems to be clearer, the suppression can be added as
@file:
too.
m

Mike

02/07/2020, 5:08 PM
You might be able to create your own annotation.
@JvmOnlyJava
Otherwise, I'd also use the "Java only" version approach. I know it's unlikely this code will still be around when Kotlin 99999 is released, but...
f

Fleshgrinder

02/07/2020, 5:16 PM
Sadly no, the
@SinceKotlin
annotation is not inheritable. Meaning, if I create a
@JavaOnly
annotation I cannot give it the same semantics as
@SinceKotlin("Java only")
has it and the symbol will be visible in both Java and Kotlin. 😞 I'll create a feature request and PR for Kotlin, we need this. Maybe something like
@PlatformOnly
since it might be useful for JS and native too.
Just wanted to write tests in Kotlin with
@SinceKotlin("Java only")
but the symbols are still visible, it has to be
@SinceKotlin("999999.999999")
or similar (so a version string). 😞 I guess the only workaround here is to create a constant that says
JAVA_ONLY
and contains such a weird number.
m

Mike

02/07/2020, 6:59 PM
Interesting....
f

Fleshgrinder

02/08/2020, 9:55 AM
m

marstran

02/10/2020, 10:54 AM
Are we deliberately creating our own Y2k here? 😄
f

Fleshgrinder

02/10/2020, 11:09 AM
The reasoning for why devs implemented things as they did that ultimately lead to Y2k were totally sound. Same here. 😉 😄
2 Views