JVM_IR KT-41214 emit PermittedSubclasses on JDK17+

This commit is contained in:
Dmitry Petrov
2021-10-08 09:57:05 +03:00
committed by TeamCityServer
parent dca4a8e722
commit 146f0f4904
41 changed files with 695 additions and 43 deletions
@@ -558,6 +558,7 @@ message IrClass {
repeated IrDeclaration declaration = 5;
repeated int32 super_type = 6 [packed=true];
optional IrInlineClassRepresentation inline_class_representation = 7;
repeated int64 sealed_subclass = 8 [packed=true];
}
message IrTypeAlias {
@@ -26,7 +26,8 @@ message PirClassCarrier {
repeated int64 typeParameters = 6;
repeated int32 superTypes = 7;
optional IrInlineClassRepresentation inlineClassRepresentation = 8;
optional int64 flags = 9 [default = 0];
repeated int64 sealedSubclasses = 9;
optional int64 flags = 10 [default = 0];
}
message PirConstructorCarrier {
@@ -348,6 +348,8 @@ class IrDeclarationDeserializer(
else -> computeMissingInlineClassRepresentationForCompatibility(this)
}
sealedSubclasses = proto.sealedSubclassList.map { deserializeIrSymbol(it) as IrClassSymbol }
fakeOverrideBuilder.enqueueClass(this, signature, compatibilityMode)
}
}
@@ -1327,6 +1327,10 @@ open class IrFileSerializer(
clazz.superTypes.forEach {
proto.addSuperType(serializeIrType(it))
}
clazz.sealedSubclasses.forEach {
proto.addSealedSubclass(serializeIrSymbol(it))
}
}
return proto.build()
@@ -134,6 +134,27 @@ public final class IrClass extends
bitField0_ |= 0x00000008;
break;
}
case 64: {
if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
sealedSubclass_ = new java.util.ArrayList<java.lang.Long>();
mutable_bitField0_ |= 0x00000080;
}
sealedSubclass_.add(input.readInt64());
break;
}
case 66: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
if (!((mutable_bitField0_ & 0x00000080) == 0x00000080) && input.getBytesUntilLimit() > 0) {
sealedSubclass_ = new java.util.ArrayList<java.lang.Long>();
mutable_bitField0_ |= 0x00000080;
}
while (input.getBytesUntilLimit() > 0) {
sealedSubclass_.add(input.readInt64());
}
input.popLimit(limit);
break;
}
}
}
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
@@ -151,6 +172,9 @@ public final class IrClass extends
if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
superType_ = java.util.Collections.unmodifiableList(superType_);
}
if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
sealedSubclass_ = java.util.Collections.unmodifiableList(sealedSubclass_);
}
try {
unknownFieldsCodedOutput.flush();
} catch (java.io.IOException e) {
@@ -330,6 +354,29 @@ public final class IrClass extends
return inlineClassRepresentation_;
}
public static final int SEALED_SUBCLASS_FIELD_NUMBER = 8;
private java.util.List<java.lang.Long> sealedSubclass_;
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public java.util.List<java.lang.Long>
getSealedSubclassList() {
return sealedSubclass_;
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public int getSealedSubclassCount() {
return sealedSubclass_.size();
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public long getSealedSubclass(int index) {
return sealedSubclass_.get(index);
}
private int sealedSubclassMemoizedSerializedSize = -1;
private void initFields() {
base_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationBase.getDefaultInstance();
name_ = 0;
@@ -338,6 +385,7 @@ public final class IrClass extends
declaration_ = java.util.Collections.emptyList();
superType_ = java.util.Collections.emptyList();
inlineClassRepresentation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation.getDefaultInstance();
sealedSubclass_ = java.util.Collections.emptyList();
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -413,6 +461,13 @@ public final class IrClass extends
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeMessage(7, inlineClassRepresentation_);
}
if (getSealedSubclassList().size() > 0) {
output.writeRawVarint32(66);
output.writeRawVarint32(sealedSubclassMemoizedSerializedSize);
}
for (int i = 0; i < sealedSubclass_.size(); i++) {
output.writeInt64NoTag(sealedSubclass_.get(i));
}
output.writeRawBytes(unknownFields);
}
@@ -460,6 +515,20 @@ public final class IrClass extends
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(7, inlineClassRepresentation_);
}
{
int dataSize = 0;
for (int i = 0; i < sealedSubclass_.size(); i++) {
dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt64SizeNoTag(sealedSubclass_.get(i));
}
size += dataSize;
if (!getSealedSubclassList().isEmpty()) {
size += 1;
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt32SizeNoTag(dataSize);
}
sealedSubclassMemoizedSerializedSize = dataSize;
}
size += unknownFields.size();
memoizedSerializedSize = size;
return size;
@@ -568,6 +637,8 @@ public final class IrClass extends
bitField0_ = (bitField0_ & ~0x00000020);
inlineClassRepresentation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000040);
sealedSubclass_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000080);
return this;
}
@@ -622,6 +693,11 @@ public final class IrClass extends
to_bitField0_ |= 0x00000008;
}
result.inlineClassRepresentation_ = inlineClassRepresentation_;
if (((bitField0_ & 0x00000080) == 0x00000080)) {
sealedSubclass_ = java.util.Collections.unmodifiableList(sealedSubclass_);
bitField0_ = (bitField0_ & ~0x00000080);
}
result.sealedSubclass_ = sealedSubclass_;
result.bitField0_ = to_bitField0_;
return result;
}
@@ -670,6 +746,16 @@ public final class IrClass extends
if (other.hasInlineClassRepresentation()) {
mergeInlineClassRepresentation(other.getInlineClassRepresentation());
}
if (!other.sealedSubclass_.isEmpty()) {
if (sealedSubclass_.isEmpty()) {
sealedSubclass_ = other.sealedSubclass_;
bitField0_ = (bitField0_ & ~0x00000080);
} else {
ensureSealedSubclassIsMutable();
sealedSubclass_.addAll(other.sealedSubclass_);
}
}
setUnknownFields(
getUnknownFields().concat(other.unknownFields));
return this;
@@ -1262,6 +1348,72 @@ public final class IrClass extends
return this;
}
private java.util.List<java.lang.Long> sealedSubclass_ = java.util.Collections.emptyList();
private void ensureSealedSubclassIsMutable() {
if (!((bitField0_ & 0x00000080) == 0x00000080)) {
sealedSubclass_ = new java.util.ArrayList<java.lang.Long>(sealedSubclass_);
bitField0_ |= 0x00000080;
}
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public java.util.List<java.lang.Long>
getSealedSubclassList() {
return java.util.Collections.unmodifiableList(sealedSubclass_);
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public int getSealedSubclassCount() {
return sealedSubclass_.size();
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public long getSealedSubclass(int index) {
return sealedSubclass_.get(index);
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public Builder setSealedSubclass(
int index, long value) {
ensureSealedSubclassIsMutable();
sealedSubclass_.set(index, value);
return this;
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public Builder addSealedSubclass(long value) {
ensureSealedSubclassIsMutable();
sealedSubclass_.add(value);
return this;
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public Builder addAllSealedSubclass(
java.lang.Iterable<? extends java.lang.Long> values) {
ensureSealedSubclassIsMutable();
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
values, sealedSubclass_);
return this;
}
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
public Builder clearSealedSubclass() {
sealedSubclass_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000080);
return this;
}
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrClass)
}
@@ -83,4 +83,17 @@ public interface IrClassOrBuilder extends
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation inline_class_representation = 7;</code>
*/
org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation getInlineClassRepresentation();
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
java.util.List<java.lang.Long> getSealedSubclassList();
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
int getSealedSubclassCount();
/**
* <code>repeated int64 sealed_subclass = 8 [packed = true];</code>
*/
long getSealedSubclass(int index);
}
@@ -137,6 +137,27 @@ public final class PirClassCarrier extends
break;
}
case 72: {
if (!((mutable_bitField0_ & 0x00000100) == 0x00000100)) {
sealedSubclasses_ = new java.util.ArrayList<java.lang.Long>();
mutable_bitField0_ |= 0x00000100;
}
sealedSubclasses_.add(input.readInt64());
break;
}
case 74: {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
if (!((mutable_bitField0_ & 0x00000100) == 0x00000100) && input.getBytesUntilLimit() > 0) {
sealedSubclasses_ = new java.util.ArrayList<java.lang.Long>();
mutable_bitField0_ |= 0x00000100;
}
while (input.getBytesUntilLimit() > 0) {
sealedSubclasses_.add(input.readInt64());
}
input.popLimit(limit);
break;
}
case 80: {
bitField0_ |= 0x00000020;
flags_ = input.readInt64();
break;
@@ -158,6 +179,9 @@ public final class PirClassCarrier extends
if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) {
superTypes_ = java.util.Collections.unmodifiableList(superTypes_);
}
if (((mutable_bitField0_ & 0x00000100) == 0x00000100)) {
sealedSubclasses_ = java.util.Collections.unmodifiableList(sealedSubclasses_);
}
try {
unknownFieldsCodedOutput.flush();
} catch (java.io.IOException e) {
@@ -338,16 +362,38 @@ public final class PirClassCarrier extends
return inlineClassRepresentation_;
}
public static final int FLAGS_FIELD_NUMBER = 9;
public static final int SEALEDSUBCLASSES_FIELD_NUMBER = 9;
private java.util.List<java.lang.Long> sealedSubclasses_;
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public java.util.List<java.lang.Long>
getSealedSubclassesList() {
return sealedSubclasses_;
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public int getSealedSubclassesCount() {
return sealedSubclasses_.size();
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public long getSealedSubclasses(int index) {
return sealedSubclasses_.get(index);
}
public static final int FLAGS_FIELD_NUMBER = 10;
private long flags_;
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000020) == 0x00000020);
}
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public long getFlags() {
return flags_;
@@ -362,6 +408,7 @@ public final class PirClassCarrier extends
typeParameters_ = java.util.Collections.emptyList();
superTypes_ = java.util.Collections.emptyList();
inlineClassRepresentation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation.getDefaultInstance();
sealedSubclasses_ = java.util.Collections.emptyList();
flags_ = 0L;
}
private byte memoizedIsInitialized = -1;
@@ -417,8 +464,11 @@ public final class PirClassCarrier extends
if (((bitField0_ & 0x00000010) == 0x00000010)) {
output.writeMessage(8, inlineClassRepresentation_);
}
for (int i = 0; i < sealedSubclasses_.size(); i++) {
output.writeInt64(9, sealedSubclasses_.get(i));
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
output.writeInt64(9, flags_);
output.writeInt64(10, flags_);
}
output.writeRawBytes(unknownFields);
}
@@ -471,9 +521,18 @@ public final class PirClassCarrier extends
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(8, inlineClassRepresentation_);
}
{
int dataSize = 0;
for (int i = 0; i < sealedSubclasses_.size(); i++) {
dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt64SizeNoTag(sealedSubclasses_.get(i));
}
size += dataSize;
size += 1 * getSealedSubclassesList().size();
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeInt64Size(9, flags_);
.computeInt64Size(10, flags_);
}
size += unknownFields.size();
memoizedSerializedSize = size;
@@ -585,8 +644,10 @@ public final class PirClassCarrier extends
bitField0_ = (bitField0_ & ~0x00000040);
inlineClassRepresentation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000080);
flags_ = 0L;
sealedSubclasses_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000100);
flags_ = 0L;
bitField0_ = (bitField0_ & ~0x00000200);
return this;
}
@@ -645,7 +706,12 @@ public final class PirClassCarrier extends
to_bitField0_ |= 0x00000010;
}
result.inlineClassRepresentation_ = inlineClassRepresentation_;
if (((from_bitField0_ & 0x00000100) == 0x00000100)) {
if (((bitField0_ & 0x00000100) == 0x00000100)) {
sealedSubclasses_ = java.util.Collections.unmodifiableList(sealedSubclasses_);
bitField0_ = (bitField0_ & ~0x00000100);
}
result.sealedSubclasses_ = sealedSubclasses_;
if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
to_bitField0_ |= 0x00000020;
}
result.flags_ = flags_;
@@ -700,6 +766,16 @@ public final class PirClassCarrier extends
if (other.hasInlineClassRepresentation()) {
mergeInlineClassRepresentation(other.getInlineClassRepresentation());
}
if (!other.sealedSubclasses_.isEmpty()) {
if (sealedSubclasses_.isEmpty()) {
sealedSubclasses_ = other.sealedSubclasses_;
bitField0_ = (bitField0_ & ~0x00000100);
} else {
ensureSealedSubclassesIsMutable();
sealedSubclasses_.addAll(other.sealedSubclasses_);
}
}
if (other.hasFlags()) {
setFlags(other.getFlags());
}
@@ -1192,33 +1268,99 @@ public final class PirClassCarrier extends
return this;
}
private long flags_ ;
/**
* <code>optional int64 flags = 9 [default = 0];</code>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000100) == 0x00000100);
private java.util.List<java.lang.Long> sealedSubclasses_ = java.util.Collections.emptyList();
private void ensureSealedSubclassesIsMutable() {
if (!((bitField0_ & 0x00000100) == 0x00000100)) {
sealedSubclasses_ = new java.util.ArrayList<java.lang.Long>(sealedSubclasses_);
bitField0_ |= 0x00000100;
}
}
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public java.util.List<java.lang.Long>
getSealedSubclassesList() {
return java.util.Collections.unmodifiableList(sealedSubclasses_);
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public int getSealedSubclassesCount() {
return sealedSubclasses_.size();
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public long getSealedSubclasses(int index) {
return sealedSubclasses_.get(index);
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public Builder setSealedSubclasses(
int index, long value) {
ensureSealedSubclassesIsMutable();
sealedSubclasses_.set(index, value);
return this;
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public Builder addSealedSubclasses(long value) {
ensureSealedSubclassesIsMutable();
sealedSubclasses_.add(value);
return this;
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public Builder addAllSealedSubclasses(
java.lang.Iterable<? extends java.lang.Long> values) {
ensureSealedSubclassesIsMutable();
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
values, sealedSubclasses_);
return this;
}
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
public Builder clearSealedSubclasses() {
sealedSubclasses_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000100);
return this;
}
private long flags_ ;
/**
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public boolean hasFlags() {
return ((bitField0_ & 0x00000200) == 0x00000200);
}
/**
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public long getFlags() {
return flags_;
}
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public Builder setFlags(long value) {
bitField0_ |= 0x00000100;
bitField0_ |= 0x00000200;
flags_ = value;
return this;
}
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
public Builder clearFlags() {
bitField0_ = (bitField0_ & ~0x00000100);
bitField0_ = (bitField0_ & ~0x00000200);
flags_ = 0L;
return this;
@@ -93,11 +93,24 @@ public interface PirClassCarrierOrBuilder extends
org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepresentation getInlineClassRepresentation();
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
java.util.List<java.lang.Long> getSealedSubclassesList();
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
int getSealedSubclassesCount();
/**
* <code>repeated int64 sealedSubclasses = 9;</code>
*/
long getSealedSubclasses(int index);
/**
* <code>optional int64 flags = 10 [default = 0];</code>
*/
boolean hasFlags();
/**
* <code>optional int64 flags = 9 [default = 0];</code>
* <code>optional int64 flags = 10 [default = 0];</code>
*/
long getFlags();
}