Peter Ertl
05/05/2021, 4:45 PMif (klass.isValueClass) {
// TODO get type of embedded value for further processing
}
update - I think I found it:
if (klass.isValue) {
val ctor = klass.primaryConstructor ?: error("value class has no primary constructor")
val valueType = ctor.parameters.firstOrNull()?.type ?: error("value class has no single parameter in constructor")
// use it
}
If somebody knows a shorter way I would appreciateephemient
05/05/2021, 5:10 PMephemient
05/05/2021, 5:11 PMPeter Ertl
05/05/2021, 5:12 PMPeter Ertl
05/05/2021, 5:12 PMephemient
05/05/2021, 5:15 PMIn fact, there are legitimate use-cases for “inlined” multi-field value classes support on pre-Valhalla JVM. Consider the following example:
@JvmInline
value class Complex(val re: Double, val im: Double)
ephemient
05/05/2021, 5:15 PM@JvmInline
that restriction will probably disappearPeter Ertl
05/05/2021, 5:18 PMPeter Ertl
05/05/2021, 5:18 PMPeter Ertl
05/05/2021, 5:18 PMPeter Ertl
05/05/2021, 5:39 PMephemient
05/05/2021, 5:47 PMephemient
05/05/2021, 5:48 PMInlineClass(1)
constructed here versus InlineClass(1)
constructed there"ephemient
05/05/2021, 5:50 PMPeter Ertl
05/05/2021, 7:15 PM