why does the compiler eagerly generate wrappers fo...
# compiler
k
why does the compiler eagerly generate wrappers for value/inline classes Wouldn't it make more sense to only generate them when necessary? Like being used with generics?
i
Could you provide an example? The compiler boxes inline classes only if this is necessary. Otherwise, it is a bug.
k
I think he means that the wrapper class is still generated even if it's never used
k
That's correct
i
It is generated because the compiler does not know, whether the class will be needed. The inline class might be declared in a library and used in another library. In this case, when we compile the first library, we do not know, how it is used in the other one. The compiler might be able to remove the class of part of it in Kotlin/JS, because of closed world model, but not on JVM.
k
This is something that was already talked about in YouTrack (sorry for the dup), but isn’t this something that could be optimized using klib? We could preserve the wrappers in the klib and only when it’s lowered to byte/bitcode remove them.
i
No