FIR: deserialize value class representation from metadata
This is necessary when jvm-abi-gen strips out private constructors. #KT-54897 Fixed
This commit is contained in:
+13
-8
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.name.*
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getName
|
||||
import org.jetbrains.kotlin.serialization.deserialization.loadValueClassRepresentation
|
||||
|
||||
fun deserializeClassToSymbol(
|
||||
classId: ClassId,
|
||||
@@ -203,27 +204,31 @@ fun deserializeClassToSymbol(
|
||||
companionObjectSymbol = (declarations.firstOrNull { it is FirRegularClass && it.isCompanion } as FirRegularClass?)?.symbol
|
||||
|
||||
contextReceivers.addAll(classDeserializer.createContextReceiversForClass(classProto))
|
||||
}.also {
|
||||
}.apply {
|
||||
if (isSealed) {
|
||||
val inheritors = classProto.sealedSubclassFqNameList.map { nameIndex ->
|
||||
ClassId.fromString(nameResolver.getQualifiedClassName(nameIndex))
|
||||
}
|
||||
it.setSealedClassInheritors(inheritors)
|
||||
setSealedClassInheritors(inheritors)
|
||||
}
|
||||
|
||||
it.valueClassRepresentation = computeValueClassRepresentation(it, session)
|
||||
valueClassRepresentation =
|
||||
classProto.loadValueClassRepresentation(context.nameResolver, context.typeTable, context.typeDeserializer::simpleType) { name ->
|
||||
val member = declarations.singleOrNull { it is FirProperty && it.receiverTypeRef == null && it.name == name }
|
||||
(member as FirProperty?)?.returnTypeRef?.coneTypeSafe()
|
||||
} ?: computeValueClassRepresentation(this, session)
|
||||
|
||||
(it.annotations as MutableList<FirAnnotation>) +=
|
||||
(annotations as MutableList<FirAnnotation>) +=
|
||||
context.annotationDeserializer.loadClassAnnotations(classProto, context.nameResolver)
|
||||
|
||||
it.versionRequirementsTable = context.versionRequirementTable
|
||||
versionRequirementsTable = context.versionRequirementTable
|
||||
|
||||
it.sourceElement = containerSource
|
||||
sourceElement = containerSource
|
||||
|
||||
it.replaceDeprecationsProvider(it.getDeprecationsProvider(session.firCachesFactory))
|
||||
replaceDeprecationsProvider(getDeprecationsProvider(session.firCachesFactory))
|
||||
|
||||
classProto.getExtensionOrNull(JvmProtoBuf.classModuleName)?.let { idx ->
|
||||
it.moduleName = nameResolver.getString(idx)
|
||||
moduleName = nameResolver.getString(idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -113,7 +113,7 @@ class FirTypeDeserializer(
|
||||
}
|
||||
}
|
||||
|
||||
private fun attributesFromAnnotations(proto: ProtoBuf.Type) =
|
||||
private fun attributesFromAnnotations(proto: ProtoBuf.Type): ConeAttributes =
|
||||
annotationDeserializer.loadTypeAnnotations(proto, nameResolver)
|
||||
.computeTypeAttributes(moduleData.session)
|
||||
|
||||
@@ -121,6 +121,11 @@ class FirTypeDeserializer(
|
||||
return type(proto, attributesFromAnnotations(proto))
|
||||
}
|
||||
|
||||
fun simpleType(proto: ProtoBuf.Type): ConeSimpleKotlinType {
|
||||
return simpleType(proto, attributesFromAnnotations(proto))
|
||||
?: ConeErrorType(ConeSimpleDiagnostic("?!id:0", DiagnosticKind.DeserializationError))
|
||||
}
|
||||
|
||||
private fun type(proto: ProtoBuf.Type, attributes: ConeAttributes): ConeKotlinType {
|
||||
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||
val lowerBound = simpleType(proto, attributes)
|
||||
|
||||
Reference in New Issue
Block a user