[IR] Fix classes TypeParameter [de]serialization
This commit is contained in:
@@ -16,6 +16,7 @@ message DescriptorReference {
|
||||
optional bool is_default_constructor = 9 [default = false];
|
||||
optional bool is_enum_entry = 10 [default = false];
|
||||
optional bool is_enum_special = 11 [default = false];
|
||||
optional bool is_type_parameter = 12 [default = false];
|
||||
}
|
||||
|
||||
message UniqId {
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ abstract class DeclarationTable(val builtIns: IrBuiltIns, val descriptorTable: D
|
||||
val index = if (value.origin == IrDeclarationOrigin.FAKE_OVERRIDE ||
|
||||
!value.isExported()
|
||||
|| value is IrVariable
|
||||
|| value is IrTypeParameter
|
||||
|| (value is IrTypeParameter && value.parent !is IrClass)
|
||||
|| value is IrValueParameter
|
||||
|| value is IrAnonymousInitializerImpl
|
||||
) {
|
||||
|
||||
+6
-1
@@ -84,7 +84,8 @@ abstract class DescriptorReferenceDeserializer(
|
||||
isDefaultConstructor: Boolean = false,
|
||||
isFakeOverride: Boolean = false,
|
||||
isGetter: Boolean = false,
|
||||
isSetter: Boolean = false
|
||||
isSetter: Boolean = false,
|
||||
isTypeParameter: Boolean = false
|
||||
): DeclarationDescriptor {
|
||||
val packageFqName = packageFqNameString.let {
|
||||
if (it == "<root>") FqName.ROOT else FqName(it)
|
||||
@@ -131,6 +132,10 @@ abstract class DescriptorReferenceDeserializer(
|
||||
.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BACKEND).single()
|
||||
}
|
||||
|
||||
if (isTypeParameter) {
|
||||
return clazz!!.declaredTypeParameters.first { it.name.asString() == name }
|
||||
}
|
||||
|
||||
if (protoIndex?.let { checkIfSpecialDescriptorId(it) } == true) {
|
||||
return resolveSpecialDescriptor(packageFqName.child(Name.identifier(name)))
|
||||
}
|
||||
|
||||
+2
-1
@@ -177,7 +177,8 @@ abstract class KotlinIrLinker(
|
||||
isDefaultConstructor = proto.isDefaultConstructor,
|
||||
isFakeOverride = proto.isFakeOverride,
|
||||
isGetter = proto.isGetter,
|
||||
isSetter = proto.isSetter
|
||||
isSetter = proto.isSetter,
|
||||
isTypeParameter = proto.isTypeParameter
|
||||
)
|
||||
|
||||
private val ByteArray.codedInputStream: org.jetbrains.kotlin.protobuf.CodedInputStream
|
||||
|
||||
+7
-1
@@ -29,7 +29,10 @@ open class DescriptorReferenceSerializer(
|
||||
}
|
||||
if (declaration is IrAnonymousInitializer) return null
|
||||
|
||||
if (descriptor is ParameterDescriptor || (descriptor is VariableDescriptor && descriptor !is PropertyDescriptor) || descriptor is TypeParameterDescriptor) return null
|
||||
if (descriptor is ParameterDescriptor ||
|
||||
(descriptor is VariableDescriptor && descriptor !is PropertyDescriptor)
|
||||
|| (declaration is IrTypeParameter && declaration.parent !is IrClass)
|
||||
) return null
|
||||
|
||||
val containingDeclaration = descriptor.containingDeclaration!!
|
||||
|
||||
@@ -49,6 +52,7 @@ open class DescriptorReferenceSerializer(
|
||||
descriptor is ClassConstructorDescriptor && containingDeclaration is ClassDescriptor && containingDeclaration.kind == ClassKind.OBJECT
|
||||
val isEnumEntry = descriptor is ClassDescriptor && descriptor.kind == ClassKind.ENUM_ENTRY
|
||||
val isEnumSpecial = declaration.origin == IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER
|
||||
val isTypeParameter = declaration is IrTypeParameter && declaration.parent is IrClass
|
||||
|
||||
|
||||
val realDeclaration = if (isFakeOverride) {
|
||||
@@ -103,6 +107,8 @@ open class DescriptorReferenceSerializer(
|
||||
proto.setIsEnumEntry(true)
|
||||
} else if (isEnumSpecial) {
|
||||
proto.setIsEnumSpecial(true)
|
||||
} else if (isTypeParameter) {
|
||||
proto.setIsTypeParameter(true)
|
||||
}
|
||||
|
||||
return proto.build()
|
||||
|
||||
+78
@@ -976,6 +976,15 @@ public final class IrKlibProtoBuf {
|
||||
* <code>optional bool is_enum_special = 11 [default = false];</code>
|
||||
*/
|
||||
boolean getIsEnumSpecial();
|
||||
|
||||
/**
|
||||
* <code>optional bool is_type_parameter = 12 [default = false];</code>
|
||||
*/
|
||||
boolean hasIsTypeParameter();
|
||||
/**
|
||||
* <code>optional bool is_type_parameter = 12 [default = false];</code>
|
||||
*/
|
||||
boolean getIsTypeParameter();
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.DescriptorReference}
|
||||
@@ -1114,6 +1123,11 @@ public final class IrKlibProtoBuf {
|
||||
isEnumSpecial_ = input.readBool();
|
||||
break;
|
||||
}
|
||||
case 96: {
|
||||
bitField0_ |= 0x00000800;
|
||||
isTypeParameter_ = input.readBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
@@ -1313,6 +1327,21 @@ public final class IrKlibProtoBuf {
|
||||
return isEnumSpecial_;
|
||||
}
|
||||
|
||||
public static final int IS_TYPE_PARAMETER_FIELD_NUMBER = 12;
|
||||
private boolean isTypeParameter_;
|
||||
/**
|
||||
* <code>optional bool is_type_parameter = 12 [default = false];</code>
|
||||
*/
|
||||
public boolean hasIsTypeParameter() {
|
||||
return ((bitField0_ & 0x00000800) == 0x00000800);
|
||||
}
|
||||
/**
|
||||
* <code>optional bool is_type_parameter = 12 [default = false];</code>
|
||||
*/
|
||||
public boolean getIsTypeParameter() {
|
||||
return isTypeParameter_;
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
packageFqName_ = org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.IrKlibProtoBuf.String.getDefaultInstance();
|
||||
classFqName_ = org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.IrKlibProtoBuf.String.getDefaultInstance();
|
||||
@@ -1325,6 +1354,7 @@ public final class IrKlibProtoBuf {
|
||||
isDefaultConstructor_ = false;
|
||||
isEnumEntry_ = false;
|
||||
isEnumSpecial_ = false;
|
||||
isTypeParameter_ = false;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
@@ -1402,6 +1432,9 @@ public final class IrKlibProtoBuf {
|
||||
if (((bitField0_ & 0x00000400) == 0x00000400)) {
|
||||
output.writeBool(11, isEnumSpecial_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000800) == 0x00000800)) {
|
||||
output.writeBool(12, isTypeParameter_);
|
||||
}
|
||||
output.writeRawBytes(unknownFields);
|
||||
}
|
||||
|
||||
@@ -1455,6 +1488,10 @@ public final class IrKlibProtoBuf {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeBoolSize(11, isEnumSpecial_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000800) == 0x00000800)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeBoolSize(12, isTypeParameter_);
|
||||
}
|
||||
size += unknownFields.size();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
@@ -1571,6 +1608,8 @@ public final class IrKlibProtoBuf {
|
||||
bitField0_ = (bitField0_ & ~0x00000200);
|
||||
isEnumSpecial_ = false;
|
||||
bitField0_ = (bitField0_ & ~0x00000400);
|
||||
isTypeParameter_ = false;
|
||||
bitField0_ = (bitField0_ & ~0x00000800);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1638,6 +1677,10 @@ public final class IrKlibProtoBuf {
|
||||
to_bitField0_ |= 0x00000400;
|
||||
}
|
||||
result.isEnumSpecial_ = isEnumSpecial_;
|
||||
if (((from_bitField0_ & 0x00000800) == 0x00000800)) {
|
||||
to_bitField0_ |= 0x00000800;
|
||||
}
|
||||
result.isTypeParameter_ = isTypeParameter_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
return result;
|
||||
}
|
||||
@@ -1677,6 +1720,9 @@ public final class IrKlibProtoBuf {
|
||||
if (other.hasIsEnumSpecial()) {
|
||||
setIsEnumSpecial(other.getIsEnumSpecial());
|
||||
}
|
||||
if (other.hasIsTypeParameter()) {
|
||||
setIsTypeParameter(other.getIsTypeParameter());
|
||||
}
|
||||
setUnknownFields(
|
||||
getUnknownFields().concat(other.unknownFields));
|
||||
return this;
|
||||
@@ -2199,6 +2245,38 @@ public final class IrKlibProtoBuf {
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean isTypeParameter_ ;
|
||||
/**
|
||||
* <code>optional bool is_type_parameter = 12 [default = false];</code>
|
||||
*/
|
||||
public boolean hasIsTypeParameter() {
|
||||
return ((bitField0_ & 0x00000800) == 0x00000800);
|
||||
}
|
||||
/**
|
||||
* <code>optional bool is_type_parameter = 12 [default = false];</code>
|
||||
*/
|
||||
public boolean getIsTypeParameter() {
|
||||
return isTypeParameter_;
|
||||
}
|
||||
/**
|
||||
* <code>optional bool is_type_parameter = 12 [default = false];</code>
|
||||
*/
|
||||
public Builder setIsTypeParameter(boolean value) {
|
||||
bitField0_ |= 0x00000800;
|
||||
isTypeParameter_ = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional bool is_type_parameter = 12 [default = false];</code>
|
||||
*/
|
||||
public Builder clearIsTypeParameter() {
|
||||
bitField0_ = (bitField0_ & ~0x00000800);
|
||||
isTypeParameter_ = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.DescriptorReference)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class DeserializedTypeParameterDescriptor(
|
||||
private val c: DeserializationContext,
|
||||
private val proto: ProtoBuf.TypeParameter,
|
||||
val proto: ProtoBuf.TypeParameter,
|
||||
index: Int
|
||||
) : AbstractLazyTypeParameterDescriptor(
|
||||
c.storageManager, c.containingDeclaration, c.nameResolver.getName(proto.name),
|
||||
|
||||
Reference in New Issue
Block a user