When int is converted into Integer (autoboxing), compiler calls public static Integer valueOf(int i);
When underlying field is converted into an instance of the value class, the compiler calls ValueClass.box-impl method which just wraps constructor. I would like to implement cache in similar way as Integer does, but I cannot override the method.
I tried sth with e.g. @JvmName @JvmStatic, but result method returns the underlying field instead of instence of the class and then it is not called when expected
public static final short box_impl/* $FF was: box-impl*/(short var0) {
return Companion.box-impl(var0);
}
How to override default factory method?