https://kotlinlang.org logo
Title
c

cbruegg

01/13/2019, 10:54 AM
I'd recommend benchmarking it, seems like autoboxing-removal itself is not implemented: https://stackoverflow.com/a/21954389/1502352 But maybe escape analysis can help in some cases, which should allow allocation on the stack instead of on the heap. I don't know for sure though.
p

Pavlo Liapota

01/13/2019, 3:30 PM
If property would be consumed where
Integer
type is expected, then yes, autoboxing will probably not be removed. But in described situation it is just enough to inline getter to see that value is auto-boxed and then directly auto-unboxed. I will try to benchmark this later. Thanks for the link, though.
c

cbruegg

01/13/2019, 3:31 PM
Question is whether it will actually be inlined. If it's very polymorphic, maybe the JVM won't do it