I wonder why exactly `private const val` symbols a...
# announcements
f
I wonder why exactly
private const val
symbols are kept in the bytecode. I guess for reflection but what if this is not required? There should be some kind of annotation to drop these symbols after they are inlined everywhere, no? (Maybe should post this in #language-proposals but wanted to first hear if someone has another reason than reflection to keep them.)
m
Hadn't noticed, but now also curious why they're kept. They can't be used from Java, and should be inlined in all Kotlin code. Perhaps there's a scenario where the compiler can't inline the
const
? Otherwise, I agree. All
private const val
should not appear in the bytecode.
f
A file containing only
private const val X = 1
produces this (IntelliJ Kotlin bytecode viewer).
So it's not about the ability to inline something, or not.
m
Sorry, I meant perhaps they're always kept because there could be a scenario where the compiler can't inline it, but rather than handling that scenario explicitly, it just generates them all. It's far-fetched at best...
f
I see, in that case it would be easily possible to change the behavior without considering it a breaking change. However, I fear it's reflection…
m
Time to bring it to the language experts and ask them.