Reified type parameters in classes

Sorry, I’ve confused you, should have provided more details.

In today’s Kotlin, we can say List<Int>. It does not translate to an actual list of primitive Int’s, but is implemented through boxing, you are right. We could probably design the interaction between reified functions and classes that work on boxed values, but preserve type information at runtime. That would be a lot of work, would be incompatible with Valhalla, wouldn’t solve any of the performance issues related to boxing, would also mess up Java APIs quite a bit (passing those runtime types as extra parameters everywhere). So, it doesn’t look too reasonable for us at the moment to do it in this half-hearted way.

There has been recently an idea of keeping the type information outside the objects, in some kind of a map. It would be more expensive, but a lot less intrusive, and probably much easier to implement. We could at one point get around to experimenting with it, but no ETA as of now.

1 Like