, is compiler smart enough to convert bar to static field (companion object)?
f
Fleshgrinder
02/09/2022, 9:38 AM
Have you checked the generated bytecode? IntelliJ has under tools a Kotlin entry where you can get the bytecode, from there you can let it generate the Java code. This will give you the answer. Afaik it is going to create a normal field.
✅ 1
d
dmitriy.novozhilov
02/09/2022, 10:57 AM
Such optimization will break contracts about compiled code, which may affect, for example, reflection, so it can not be performed