FIR: Support (de)serialization of context receivers

This commit is contained in:
Denis.Zharkov
2022-03-24 13:45:53 +03:00
committed by teamcity
parent dfc736161a
commit 0ba5c528d0
3 changed files with 78 additions and 1 deletions
@@ -189,6 +189,17 @@ class FirElementSerializer private constructor(
}
}
if (klass is FirRegularClass) {
for (contextReceiver in klass.contextReceivers) {
val typeRef = contextReceiver.typeRef
if (useTypeTable()) {
builder.addContextReceiverTypeId(typeId(typeRef))
} else {
builder.addContextReceiverType(typeProto(contextReceiver.typeRef))
}
}
}
if (versionRequirementTable == null) error("Version requirements must be serialized for classes: ${klass.render()}")
builder.addAllVersionRequirement(versionRequirementTable.serializeVersionRequirements(klass))
@@ -312,6 +323,15 @@ class FirElementSerializer private constructor(
builder.addTypeParameter(local.typeParameterProto(typeParameter))
}
for (contextReceiver in property.contextReceivers) {
val typeRef = contextReceiver.typeRef
if (useTypeTable()) {
builder.addContextReceiverTypeId(typeId(typeRef))
} else {
builder.addContextReceiverType(typeProto(contextReceiver.typeRef))
}
}
val receiverTypeRef = property.receiverTypeRef
if (receiverTypeRef != null) {
if (useTypeTable()) {
@@ -386,6 +406,15 @@ class FirElementSerializer private constructor(
builder.addTypeParameter(local.typeParameterProto(typeParameter))
}
for (contextReceiver in function.contextReceivers) {
val typeRef = contextReceiver.typeRef
if (useTypeTable()) {
builder.addContextReceiverTypeId(typeId(typeRef))
} else {
builder.addContextReceiverType(typeProto(contextReceiver.typeRef))
}
}
val receiverTypeRef = function.receiverTypeRef
if (receiverTypeRef != null) {
if (useTypeTable()) {