wrapper around some type. However, it introduces runtime overhead due to additional heap allocations. Moreover, if the wrapped type is primitive, the performance hit is terrible, because primitive types are usually heavily optimized by the runtime, while their wrappers don't get any special treatment. To solve such issues, Kotlin introduces a special kind of class called an inline class” https://kotlinlang.org/docs/reference/inline-classes.html
both, the wrapper type and the underlying type. The compiler prefers using the underlying (wrapped) type of an inline class to optimize the code as much as possible. • In certain situations, however, the compiler needs to use the wrapper itself, so it will be generated during compilation. How does inline classes work
nullability of the underlying type ◦ nullability at the usage site • Both cases can happen for underlying reference type or underlying primitive type Autoboxing
a single value parameter • Inline class must have a single read-only (val) property as an underlying value, which is defined in primary constructor • Underlying value cannot be of the same type that is containing inline class Limitations & restrictions
must be final Inline class can implement only interfaces • Inline class must be a top level class • Inline class cannot have backing fields • Hence, it follows that inline class can have only simple computable properties (no lateinit/delegated properties) Limitations & restrictions