diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt index 3d78f389bac..33e5f16f190 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt @@ -9,10 +9,7 @@ import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageVersionSettings -import org.jetbrains.kotlin.descriptors.ClassKind -import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.descriptors.Visibilities -import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* @@ -218,21 +215,32 @@ class FirElementSerializer private constructor( builder.companionObjectName = getSimpleNameIndex(companionObject.name) } - val representation = (klass as? FirRegularClass)?.inlineClassRepresentation - if (representation != null) { - builder.inlineClassUnderlyingPropertyName = getSimpleNameIndex(representation.underlyingPropertyName) + when (val representation = (klass as? FirRegularClass)?.valueClassRepresentation) { + is InlineClassRepresentation -> { + builder.inlineClassUnderlyingPropertyName = getSimpleNameIndex(representation.underlyingPropertyName) - val property = callableMembers.single { - it is FirProperty && it.receiverParameter == null && it.name == representation.underlyingPropertyName - } + val property = callableMembers.single { + it is FirProperty && it.receiverParameter == null && it.name == representation.underlyingPropertyName + } - if (!property.visibility.isPublicAPI) { - if (useTypeTable()) { - builder.inlineClassUnderlyingTypeId = typeId(representation.underlyingType) - } else { - builder.setInlineClassUnderlyingType(typeProto(representation.underlyingType)) + if (!property.visibility.isPublicAPI) { + if (useTypeTable()) { + builder.inlineClassUnderlyingTypeId = typeId(representation.underlyingType) + } else { + builder.setInlineClassUnderlyingType(typeProto(representation.underlyingType)) + } } } + is MultiFieldValueClassRepresentation -> { + val namesToTypes = representation.underlyingPropertyNamesToTypes + builder.addAllMultiFieldValueClassUnderlyingName(namesToTypes.map { (name, _) -> getSimpleNameIndex(name) }) + if (useTypeTable()) { + builder.addAllMultiFieldValueClassUnderlyingTypeId(namesToTypes.map { (_, kotlinType) -> typeId(kotlinType) }) + } else { + builder.addAllMultiFieldValueClassUnderlyingType(namesToTypes.map { (_, kotlinType) -> typeProto(kotlinType).build() }) + } + } + null -> {} } if (klass is FirRegularClass) {