diff --git a/build-common/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt b/build-common/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt
index adb3f01e1e2..cbe69082571 100644
--- a/build-common/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt
+++ b/build-common/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt
@@ -125,6 +125,8 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
if (!checkEqualsClassEnumEntry(old, new)) return false
+ if (!checkEqualsClassSealedSubclassFqName(old, new)) return false
+
if (old.hasTypeTable() != new.hasTypeTable()) return false
if (old.hasTypeTable()) {
if (!checkEquals(old.typeTable, new.typeTable)) return false
@@ -160,6 +162,7 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
PROPERTY_LIST,
TYPE_ALIAS_LIST,
ENUM_ENTRY_LIST,
+ SEALED_SUBCLASS_FQ_NAME_LIST,
TYPE_TABLE,
SINCE_KOTLIN_INFO,
SINCE_KOTLIN_INFO_TABLE,
@@ -199,6 +202,8 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
if (!checkEqualsClassEnumEntry(old, new)) result.add(ProtoBufClassKind.ENUM_ENTRY_LIST)
+ if (!checkEqualsClassSealedSubclassFqName(old, new)) result.add(ProtoBufClassKind.SEALED_SUBCLASS_FQ_NAME_LIST)
+
if (old.hasTypeTable() != new.hasTypeTable()) result.add(ProtoBufClassKind.TYPE_TABLE)
if (old.hasTypeTable()) {
if (!checkEquals(old.typeTable, new.typeTable)) result.add(ProtoBufClassKind.TYPE_TABLE)
@@ -850,6 +855,16 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
return true
}
+ open fun checkEqualsClassSealedSubclassFqName(old: ProtoBuf.Class, new: ProtoBuf.Class): Boolean {
+ if (old.sealedSubclassFqNameCount != new.sealedSubclassFqNameCount) return false
+
+ for(i in 0..old.sealedSubclassFqNameCount - 1) {
+ if (!checkClassIdEquals(old.getSealedSubclassFqName(i), new.getSealedSubclassFqName(i))) return false
+ }
+
+ return true
+ }
+
open fun checkEqualsFunctionTypeParameter(old: ProtoBuf.Function, new: ProtoBuf.Function): Boolean {
if (old.typeParameterCount != new.typeParameterCount) return false
@@ -1090,6 +1105,10 @@ fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) ->
hashCode = 31 * hashCode + getEnumEntry(i).hashCode(stringIndexes, fqNameIndexes)
}
+ for(i in 0..sealedSubclassFqNameCount - 1) {
+ hashCode = 31 * hashCode + fqNameIndexes(getSealedSubclassFqName(i))
+ }
+
if (hasTypeTable()) {
hashCode = 31 * hashCode + typeTable.hashCode(stringIndexes, fqNameIndexes)
}
diff --git a/build-common/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt b/build-common/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt
index 789c52ee8fe..50fe8daedf2 100644
--- a/build-common/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt
+++ b/build-common/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt
@@ -217,6 +217,9 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot
ProtoBufClassKind.ENUM_ENTRY_LIST -> {
isClassAffected = true
}
+ ProtoBufClassKind.SEALED_SUBCLASS_FQ_NAME_LIST -> {
+ // TODO
+ }
ProtoBufClassKind.TYPE_TABLE -> {
// TODO
}
diff --git a/build-common/test/org/jetbrains/kotlin/serialization/DebugProtoBuf.java b/build-common/test/org/jetbrains/kotlin/serialization/DebugProtoBuf.java
index af748604dc1..d7c5408770c 100644
--- a/build-common/test/org/jetbrains/kotlin/serialization/DebugProtoBuf.java
+++ b/build-common/test/org/jetbrains/kotlin/serialization/DebugProtoBuf.java
@@ -9972,6 +9972,19 @@ public final class DebugProtoBuf {
org.jetbrains.kotlin.serialization.DebugProtoBuf.EnumEntryOrBuilder getEnumEntryOrBuilder(
int index);
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ java.util.List getSealedSubclassFqNameList();
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ int getSealedSubclassFqNameCount();
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ int getSealedSubclassFqName(int index);
+
/**
* optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
*/
@@ -10181,6 +10194,27 @@ public final class DebugProtoBuf {
enumEntry_.add(input.readMessage(org.jetbrains.kotlin.serialization.DebugProtoBuf.EnumEntry.PARSER, extensionRegistry));
break;
}
+ case 128: {
+ if (!((mutable_bitField0_ & 0x00001000) == 0x00001000)) {
+ sealedSubclassFqName_ = new java.util.ArrayList();
+ mutable_bitField0_ |= 0x00001000;
+ }
+ sealedSubclassFqName_.add(input.readInt32());
+ break;
+ }
+ case 130: {
+ int length = input.readRawVarint32();
+ int limit = input.pushLimit(length);
+ if (!((mutable_bitField0_ & 0x00001000) == 0x00001000) && input.getBytesUntilLimit() > 0) {
+ sealedSubclassFqName_ = new java.util.ArrayList();
+ mutable_bitField0_ |= 0x00001000;
+ }
+ while (input.getBytesUntilLimit() > 0) {
+ sealedSubclassFqName_.add(input.readInt32());
+ }
+ input.popLimit(limit);
+ break;
+ }
case 242: {
org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable.Builder subBuilder = null;
if (((bitField0_ & 0x00000008) == 0x00000008)) {
@@ -10247,6 +10281,9 @@ public final class DebugProtoBuf {
if (((mutable_bitField0_ & 0x00000800) == 0x00000800)) {
enumEntry_ = java.util.Collections.unmodifiableList(enumEntry_);
}
+ if (((mutable_bitField0_ & 0x00001000) == 0x00001000)) {
+ sealedSubclassFqName_ = java.util.Collections.unmodifiableList(sealedSubclassFqName_);
+ }
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
@@ -10768,6 +10805,29 @@ public final class DebugProtoBuf {
return enumEntry_.get(index);
}
+ public static final int SEALED_SUBCLASS_FQ_NAME_FIELD_NUMBER = 16;
+ private java.util.List sealedSubclassFqName_;
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public java.util.List
+ getSealedSubclassFqNameList() {
+ return sealedSubclassFqName_;
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public int getSealedSubclassFqNameCount() {
+ return sealedSubclassFqName_.size();
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public int getSealedSubclassFqName(int index) {
+ return sealedSubclassFqName_.get(index);
+ }
+ private int sealedSubclassFqNameMemoizedSerializedSize = -1;
+
public static final int TYPE_TABLE_FIELD_NUMBER = 30;
private org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable typeTable_;
/**
@@ -10846,6 +10906,7 @@ public final class DebugProtoBuf {
property_ = java.util.Collections.emptyList();
typeAlias_ = java.util.Collections.emptyList();
enumEntry_ = java.util.Collections.emptyList();
+ sealedSubclassFqName_ = java.util.Collections.emptyList();
typeTable_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable.getDefaultInstance();
sinceKotlinInfo_ = 0;
sinceKotlinInfoTable_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.SinceKotlinInfoTable.getDefaultInstance();
@@ -10966,6 +11027,13 @@ public final class DebugProtoBuf {
for (int i = 0; i < enumEntry_.size(); i++) {
output.writeMessage(13, enumEntry_.get(i));
}
+ if (getSealedSubclassFqNameList().size() > 0) {
+ output.writeRawVarint32(130);
+ output.writeRawVarint32(sealedSubclassFqNameMemoizedSerializedSize);
+ }
+ for (int i = 0; i < sealedSubclassFqName_.size(); i++) {
+ output.writeInt32NoTag(sealedSubclassFqName_.get(i));
+ }
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeMessage(30, typeTable_);
}
@@ -11053,6 +11121,20 @@ public final class DebugProtoBuf {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(13, enumEntry_.get(i));
}
+ {
+ int dataSize = 0;
+ for (int i = 0; i < sealedSubclassFqName_.size(); i++) {
+ dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream
+ .computeInt32SizeNoTag(sealedSubclassFqName_.get(i));
+ }
+ size += dataSize;
+ if (!getSealedSubclassFqNameList().isEmpty()) {
+ size += 2;
+ size += org.jetbrains.kotlin.protobuf.CodedOutputStream
+ .computeInt32SizeNoTag(dataSize);
+ }
+ sealedSubclassFqNameMemoizedSerializedSize = dataSize;
+ }
if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(30, typeTable_);
@@ -11245,20 +11327,22 @@ public final class DebugProtoBuf {
} else {
enumEntryBuilder_.clear();
}
+ sealedSubclassFqName_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00001000);
if (typeTableBuilder_ == null) {
typeTable_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable.getDefaultInstance();
} else {
typeTableBuilder_.clear();
}
- bitField0_ = (bitField0_ & ~0x00001000);
- sinceKotlinInfo_ = 0;
bitField0_ = (bitField0_ & ~0x00002000);
+ sinceKotlinInfo_ = 0;
+ bitField0_ = (bitField0_ & ~0x00004000);
if (sinceKotlinInfoTableBuilder_ == null) {
sinceKotlinInfoTable_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.SinceKotlinInfoTable.getDefaultInstance();
} else {
sinceKotlinInfoTableBuilder_.clear();
}
- bitField0_ = (bitField0_ & ~0x00004000);
+ bitField0_ = (bitField0_ & ~0x00008000);
return this;
}
@@ -11372,7 +11456,12 @@ public final class DebugProtoBuf {
} else {
result.enumEntry_ = enumEntryBuilder_.build();
}
- if (((from_bitField0_ & 0x00001000) == 0x00001000)) {
+ if (((bitField0_ & 0x00001000) == 0x00001000)) {
+ sealedSubclassFqName_ = java.util.Collections.unmodifiableList(sealedSubclassFqName_);
+ bitField0_ = (bitField0_ & ~0x00001000);
+ }
+ result.sealedSubclassFqName_ = sealedSubclassFqName_;
+ if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
to_bitField0_ |= 0x00000008;
}
if (typeTableBuilder_ == null) {
@@ -11380,11 +11469,11 @@ public final class DebugProtoBuf {
} else {
result.typeTable_ = typeTableBuilder_.build();
}
- if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
+ if (((from_bitField0_ & 0x00004000) == 0x00004000)) {
to_bitField0_ |= 0x00000010;
}
result.sinceKotlinInfo_ = sinceKotlinInfo_;
- if (((from_bitField0_ & 0x00004000) == 0x00004000)) {
+ if (((from_bitField0_ & 0x00008000) == 0x00008000)) {
to_bitField0_ |= 0x00000020;
}
if (sinceKotlinInfoTableBuilder_ == null) {
@@ -11619,6 +11708,16 @@ public final class DebugProtoBuf {
}
}
}
+ if (!other.sealedSubclassFqName_.isEmpty()) {
+ if (sealedSubclassFqName_.isEmpty()) {
+ sealedSubclassFqName_ = other.sealedSubclassFqName_;
+ bitField0_ = (bitField0_ & ~0x00001000);
+ } else {
+ ensureSealedSubclassFqNameIsMutable();
+ sealedSubclassFqName_.addAll(other.sealedSubclassFqName_);
+ }
+ onChanged();
+ }
if (other.hasTypeTable()) {
mergeTypeTable(other.getTypeTable());
}
@@ -13656,6 +13755,72 @@ public final class DebugProtoBuf {
return enumEntryBuilder_;
}
+ private java.util.List sealedSubclassFqName_ = java.util.Collections.emptyList();
+ private void ensureSealedSubclassFqNameIsMutable() {
+ if (!((bitField0_ & 0x00001000) == 0x00001000)) {
+ sealedSubclassFqName_ = new java.util.ArrayList(sealedSubclassFqName_);
+ bitField0_ |= 0x00001000;
+ }
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public java.util.List
+ getSealedSubclassFqNameList() {
+ return java.util.Collections.unmodifiableList(sealedSubclassFqName_);
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public int getSealedSubclassFqNameCount() {
+ return sealedSubclassFqName_.size();
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public int getSealedSubclassFqName(int index) {
+ return sealedSubclassFqName_.get(index);
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public Builder setSealedSubclassFqName(
+ int index, int value) {
+ ensureSealedSubclassFqNameIsMutable();
+ sealedSubclassFqName_.set(index, value);
+ onChanged();
+ return this;
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public Builder addSealedSubclassFqName(int value) {
+ ensureSealedSubclassFqNameIsMutable();
+ sealedSubclassFqName_.add(value);
+ onChanged();
+ return this;
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public Builder addAllSealedSubclassFqName(
+ java.lang.Iterable extends java.lang.Integer> values) {
+ ensureSealedSubclassFqNameIsMutable();
+ org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
+ values, sealedSubclassFqName_);
+ onChanged();
+ return this;
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public Builder clearSealedSubclassFqName() {
+ sealedSubclassFqName_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00001000);
+ onChanged();
+ return this;
+ }
+
private org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable typeTable_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable.getDefaultInstance();
private org.jetbrains.kotlin.protobuf.SingleFieldBuilder<
org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable, org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable.Builder, org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTableOrBuilder> typeTableBuilder_;
@@ -13663,7 +13828,7 @@ public final class DebugProtoBuf {
* optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
*/
public boolean hasTypeTable() {
- return ((bitField0_ & 0x00001000) == 0x00001000);
+ return ((bitField0_ & 0x00002000) == 0x00002000);
}
/**
* optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
@@ -13688,7 +13853,7 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.setMessage(value);
}
- bitField0_ |= 0x00001000;
+ bitField0_ |= 0x00002000;
return this;
}
/**
@@ -13702,7 +13867,7 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.setMessage(builderForValue.build());
}
- bitField0_ |= 0x00001000;
+ bitField0_ |= 0x00002000;
return this;
}
/**
@@ -13710,7 +13875,7 @@ public final class DebugProtoBuf {
*/
public Builder mergeTypeTable(org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable value) {
if (typeTableBuilder_ == null) {
- if (((bitField0_ & 0x00001000) == 0x00001000) &&
+ if (((bitField0_ & 0x00002000) == 0x00002000) &&
typeTable_ != org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable.getDefaultInstance()) {
typeTable_ =
org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable.newBuilder(typeTable_).mergeFrom(value).buildPartial();
@@ -13721,7 +13886,7 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.mergeFrom(value);
}
- bitField0_ |= 0x00001000;
+ bitField0_ |= 0x00002000;
return this;
}
/**
@@ -13734,14 +13899,14 @@ public final class DebugProtoBuf {
} else {
typeTableBuilder_.clear();
}
- bitField0_ = (bitField0_ & ~0x00001000);
+ bitField0_ = (bitField0_ & ~0x00002000);
return this;
}
/**
* optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
*/
public org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeTable.Builder getTypeTableBuilder() {
- bitField0_ |= 0x00001000;
+ bitField0_ |= 0x00002000;
onChanged();
return getTypeTableFieldBuilder().getBuilder();
}
@@ -13781,7 +13946,7 @@ public final class DebugProtoBuf {
*
*/
public boolean hasSinceKotlinInfo() {
- return ((bitField0_ & 0x00002000) == 0x00002000);
+ return ((bitField0_ & 0x00004000) == 0x00004000);
}
/**
* optional int32 sinceKotlinInfo = 31;
@@ -13801,7 +13966,7 @@ public final class DebugProtoBuf {
*
*/
public Builder setSinceKotlinInfo(int value) {
- bitField0_ |= 0x00002000;
+ bitField0_ |= 0x00004000;
sinceKotlinInfo_ = value;
onChanged();
return this;
@@ -13814,7 +13979,7 @@ public final class DebugProtoBuf {
*
*/
public Builder clearSinceKotlinInfo() {
- bitField0_ = (bitField0_ & ~0x00002000);
+ bitField0_ = (bitField0_ & ~0x00004000);
sinceKotlinInfo_ = 0;
onChanged();
return this;
@@ -13827,7 +13992,7 @@ public final class DebugProtoBuf {
* optional .org.jetbrains.kotlin.serialization.SinceKotlinInfoTable since_kotlin_info_table = 32;
*/
public boolean hasSinceKotlinInfoTable() {
- return ((bitField0_ & 0x00004000) == 0x00004000);
+ return ((bitField0_ & 0x00008000) == 0x00008000);
}
/**
* optional .org.jetbrains.kotlin.serialization.SinceKotlinInfoTable since_kotlin_info_table = 32;
@@ -13852,7 +14017,7 @@ public final class DebugProtoBuf {
} else {
sinceKotlinInfoTableBuilder_.setMessage(value);
}
- bitField0_ |= 0x00004000;
+ bitField0_ |= 0x00008000;
return this;
}
/**
@@ -13866,7 +14031,7 @@ public final class DebugProtoBuf {
} else {
sinceKotlinInfoTableBuilder_.setMessage(builderForValue.build());
}
- bitField0_ |= 0x00004000;
+ bitField0_ |= 0x00008000;
return this;
}
/**
@@ -13874,7 +14039,7 @@ public final class DebugProtoBuf {
*/
public Builder mergeSinceKotlinInfoTable(org.jetbrains.kotlin.serialization.DebugProtoBuf.SinceKotlinInfoTable value) {
if (sinceKotlinInfoTableBuilder_ == null) {
- if (((bitField0_ & 0x00004000) == 0x00004000) &&
+ if (((bitField0_ & 0x00008000) == 0x00008000) &&
sinceKotlinInfoTable_ != org.jetbrains.kotlin.serialization.DebugProtoBuf.SinceKotlinInfoTable.getDefaultInstance()) {
sinceKotlinInfoTable_ =
org.jetbrains.kotlin.serialization.DebugProtoBuf.SinceKotlinInfoTable.newBuilder(sinceKotlinInfoTable_).mergeFrom(value).buildPartial();
@@ -13885,7 +14050,7 @@ public final class DebugProtoBuf {
} else {
sinceKotlinInfoTableBuilder_.mergeFrom(value);
}
- bitField0_ |= 0x00004000;
+ bitField0_ |= 0x00008000;
return this;
}
/**
@@ -13898,14 +14063,14 @@ public final class DebugProtoBuf {
} else {
sinceKotlinInfoTableBuilder_.clear();
}
- bitField0_ = (bitField0_ & ~0x00004000);
+ bitField0_ = (bitField0_ & ~0x00008000);
return this;
}
/**
* optional .org.jetbrains.kotlin.serialization.SinceKotlinInfoTable since_kotlin_info_table = 32;
*/
public org.jetbrains.kotlin.serialization.DebugProtoBuf.SinceKotlinInfoTable.Builder getSinceKotlinInfoTableBuilder() {
- bitField0_ |= 0x00004000;
+ bitField0_ |= 0x00008000;
onChanged();
return getSinceKotlinInfoTableFieldBuilder().getBuilder();
}
@@ -27296,7 +27461,7 @@ public final class DebugProtoBuf {
"ter.Variance:\003INV\022=\n\013upper_bound\030\005 \003(\0132(" +
".org.jetbrains.kotlin.serialization.Type" +
"\022\026\n\016upper_bound_id\030\006 \003(\005\"$\n\010Variance\022\006\n\002" +
- "IN\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002*\005\010d\020\350\007\"\236\007\n\005Class\022" +
+ "IN\020\000\022\007\n\003OUT\020\001\022\007\n\003INV\020\002*\005\010d\020\350\007\"\307\007\n\005Class\022" +
"\020\n\005flags\030\001 \001(\005:\0016\022\025\n\007fq_name\030\003 \002(\005B\004\220\265\030\001",
"\022#\n\025companion_object_name\030\004 \001(\005B\004\210\265\030\001\022I\n" +
"\016type_parameter\030\005 \003(\01321.org.jetbrains.ko" +
@@ -27312,86 +27477,87 @@ public final class DebugProtoBuf {
"_alias\030\013 \003(\0132-.org.jetbrains.kotlin.seri" +
"alization.TypeAlias\022A\n\nenum_entry\030\r \003(\0132" +
"-.org.jetbrains.kotlin.serialization.Enu" +
- "mEntry\022A\n\ntype_table\030\036 \001(\0132-.org.jetbrai" +
- "ns.kotlin.serialization.TypeTable\022\027\n\017sin" +
- "ceKotlinInfo\030\037 \001(\005\022Y\n\027since_kotlin_info_" +
- "table\030 \001(\01328.org.jetbrains.kotlin.seria" +
- "lization.SinceKotlinInfoTable\"x\n\004Kind\022\t\n" +
- "\005CLASS\020\000\022\r\n\tINTERFACE\020\001\022\016\n\nENUM_CLASS\020\002\022",
- "\016\n\nENUM_ENTRY\020\003\022\024\n\020ANNOTATION_CLASS\020\004\022\n\n" +
- "\006OBJECT\020\005\022\024\n\020COMPANION_OBJECT\020\006*\005\010d\020\310\001\"\361" +
- "\002\n\007Package\022>\n\010function\030\003 \003(\0132,.org.jetbr" +
- "ains.kotlin.serialization.Function\022>\n\010pr" +
- "operty\030\004 \003(\0132,.org.jetbrains.kotlin.seri" +
- "alization.Property\022A\n\ntype_alias\030\005 \003(\0132-" +
+ "mEntry\022\'\n\027sealed_subclass_fq_name\030\020 \003(\005B" +
+ "\006\020\001\220\265\030\001\022A\n\ntype_table\030\036 \001(\0132-.org.jetbra" +
+ "ins.kotlin.serialization.TypeTable\022\027\n\017si" +
+ "nceKotlinInfo\030\037 \001(\005\022Y\n\027since_kotlin_info" +
+ "_table\030 \001(\01328.org.jetbrains.kotlin.seri" +
+ "alization.SinceKotlinInfoTable\"x\n\004Kind\022\t",
+ "\n\005CLASS\020\000\022\r\n\tINTERFACE\020\001\022\016\n\nENUM_CLASS\020\002" +
+ "\022\016\n\nENUM_ENTRY\020\003\022\024\n\020ANNOTATION_CLASS\020\004\022\n" +
+ "\n\006OBJECT\020\005\022\024\n\020COMPANION_OBJECT\020\006*\005\010d\020\310\001\"" +
+ "\361\002\n\007Package\022>\n\010function\030\003 \003(\0132,.org.jetb" +
+ "rains.kotlin.serialization.Function\022>\n\010p" +
+ "roperty\030\004 \003(\0132,.org.jetbrains.kotlin.ser" +
+ "ialization.Property\022A\n\ntype_alias\030\005 \003(\0132" +
+ "-.org.jetbrains.kotlin.serialization.Typ" +
+ "eAlias\022A\n\ntype_table\030\036 \001(\0132-.org.jetbrai" +
+ "ns.kotlin.serialization.TypeTable\022Y\n\027sin",
+ "ce_kotlin_info_table\030 \001(\01328.org.jetbrai" +
+ "ns.kotlin.serialization.SinceKotlinInfoT" +
+ "able*\005\010d\020\310\001\"_\n\tTypeTable\0226\n\004type\030\001 \003(\0132(" +
".org.jetbrains.kotlin.serialization.Type" +
- "Alias\022A\n\ntype_table\030\036 \001(\0132-.org.jetbrain" +
- "s.kotlin.serialization.TypeTable\022Y\n\027sinc" +
- "e_kotlin_info_table\030 \001(\01328.org.jetbrain",
- "s.kotlin.serialization.SinceKotlinInfoTa" +
- "ble*\005\010d\020\310\001\"_\n\tTypeTable\0226\n\004type\030\001 \003(\0132(." +
- "org.jetbrains.kotlin.serialization.Type\022" +
- "\032\n\016first_nullable\030\002 \001(\005:\002-1\"\214\001\n\013Construc" +
- "tor\022\020\n\005flags\030\001 \001(\005:\0016\022K\n\017value_parameter" +
- "\030\002 \003(\01322.org.jetbrains.kotlin.serializat" +
- "ion.ValueParameter\022\027\n\017sinceKotlinInfo\030\037 " +
- "\001(\005*\005\010d\020\310\001\"\363\003\n\010Function\022\020\n\005flags\030\t \001(\005:\001" +
- "6\022\024\n\told_flags\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004\210" +
- "\265\030\001\022=\n\013return_type\030\003 \001(\0132(.org.jetbrains",
- ".kotlin.serialization.Type\022\026\n\016return_typ" +
- "e_id\030\007 \001(\005\022I\n\016type_parameter\030\004 \003(\01321.org" +
- ".jetbrains.kotlin.serialization.TypePara" +
- "meter\022?\n\rreceiver_type\030\005 \001(\0132(.org.jetbr" +
- "ains.kotlin.serialization.Type\022\030\n\020receiv" +
- "er_type_id\030\010 \001(\005\022K\n\017value_parameter\030\006 \003(" +
- "\01322.org.jetbrains.kotlin.serialization.V" +
- "alueParameter\022A\n\ntype_table\030\036 \001(\0132-.org." +
- "jetbrains.kotlin.serialization.TypeTable" +
- "\022\027\n\017sinceKotlinInfo\030\037 \001(\005*\005\010d\020\310\001\"\350\003\n\010Pro",
- "perty\022\022\n\005flags\030\013 \001(\005:\003518\022\027\n\told_flags\030\001" +
- " \001(\005:\0042054\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022=\n\013return" +
- "_type\030\003 \001(\0132(.org.jetbrains.kotlin.seria" +
- "lization.Type\022\026\n\016return_type_id\030\t \001(\005\022I\n" +
- "\016type_parameter\030\004 \003(\01321.org.jetbrains.ko" +
- "tlin.serialization.TypeParameter\022?\n\rrece" +
- "iver_type\030\005 \001(\0132(.org.jetbrains.kotlin.s" +
- "erialization.Type\022\030\n\020receiver_type_id\030\n " +
- "\001(\005\022R\n\026setter_value_parameter\030\006 \001(\01322.or" +
- "g.jetbrains.kotlin.serialization.ValuePa",
- "rameter\022\024\n\014getter_flags\030\007 \001(\005\022\024\n\014setter_" +
- "flags\030\010 \001(\005\022\027\n\017sinceKotlinInfo\030\037 \001(\005*\005\010d" +
- "\020\310\001\"\355\001\n\016ValueParameter\022\020\n\005flags\030\001 \001(\005:\0010" +
- "\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0226\n\004type\030\003 \001(\0132(.org" +
- ".jetbrains.kotlin.serialization.Type\022\017\n\007" +
- "type_id\030\005 \001(\005\022E\n\023vararg_element_type\030\004 \001" +
- "(\0132(.org.jetbrains.kotlin.serialization." +
- "Type\022\036\n\026vararg_element_type_id\030\006 \001(\005*\005\010d" +
- "\020\310\001\"\232\003\n\tTypeAlias\022\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004n" +
- "ame\030\002 \002(\005B\004\210\265\030\001\022I\n\016type_parameter\030\003 \003(\0132",
- "1.org.jetbrains.kotlin.serialization.Typ" +
- "eParameter\022A\n\017underlying_type\030\004 \001(\0132(.or" +
- "g.jetbrains.kotlin.serialization.Type\022\032\n" +
- "\022underlying_type_id\030\005 \001(\005\022?\n\rexpanded_ty" +
- "pe\030\006 \001(\0132(.org.jetbrains.kotlin.serializ" +
- "ation.Type\022\030\n\020expanded_type_id\030\007 \001(\005\022B\n\n" +
- "annotation\030\010 \003(\0132..org.jetbrains.kotlin." +
- "serialization.Annotation\022\027\n\017sinceKotlinI" +
- "nfo\030\037 \001(\005*\005\010d\020\310\001\"&\n\tEnumEntry\022\022\n\004name\030\001 " +
- "\001(\005B\004\210\265\030\001*\005\010d\020\310\001\"\341\001\n\017SinceKotlinInfo\022\017\n\007",
- "version\030\001 \001(\005\022\024\n\014version_full\030\002 \001(\005\022O\n\005l" +
- "evel\030\003 \001(\01629.org.jetbrains.kotlin.serial" +
- "ization.SinceKotlinInfo.Level:\005ERROR\022\022\n\n" +
- "error_code\030\004 \001(\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001\"" +
- "+\n\005Level\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HIDD" +
- "EN\020\002\"Y\n\024SinceKotlinInfoTable\022A\n\004info\030\001 \003" +
- "(\01323.org.jetbrains.kotlin.serialization." +
- "SinceKotlinInfo*9\n\010Modality\022\t\n\005FINAL\020\000\022\010" +
- "\n\004OPEN\020\001\022\014\n\010ABSTRACT\020\002\022\n\n\006SEALED\020\003*b\n\nVi" +
- "sibility\022\014\n\010INTERNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tP",
- "ROTECTED\020\002\022\n\n\006PUBLIC\020\003\022\023\n\017PRIVATE_TO_THI" +
- "S\020\004\022\t\n\005LOCAL\020\005*Q\n\nMemberKind\022\017\n\013DECLARAT" +
- "ION\020\000\022\021\n\rFAKE_OVERRIDE\020\001\022\016\n\nDELEGATION\020\002" +
- "\022\017\n\013SYNTHESIZED\020\003B\017B\rDebugProtoBuf"
+ "\022\032\n\016first_nullable\030\002 \001(\005:\002-1\"\214\001\n\013Constru" +
+ "ctor\022\020\n\005flags\030\001 \001(\005:\0016\022K\n\017value_paramete" +
+ "r\030\002 \003(\01322.org.jetbrains.kotlin.serializa" +
+ "tion.ValueParameter\022\027\n\017sinceKotlinInfo\030\037" +
+ " \001(\005*\005\010d\020\310\001\"\363\003\n\010Function\022\020\n\005flags\030\t \001(\005:" +
+ "\0016\022\024\n\told_flags\030\001 \001(\005:\0016\022\022\n\004name\030\002 \002(\005B\004",
+ "\210\265\030\001\022=\n\013return_type\030\003 \001(\0132(.org.jetbrain" +
+ "s.kotlin.serialization.Type\022\026\n\016return_ty" +
+ "pe_id\030\007 \001(\005\022I\n\016type_parameter\030\004 \003(\01321.or" +
+ "g.jetbrains.kotlin.serialization.TypePar" +
+ "ameter\022?\n\rreceiver_type\030\005 \001(\0132(.org.jetb" +
+ "rains.kotlin.serialization.Type\022\030\n\020recei" +
+ "ver_type_id\030\010 \001(\005\022K\n\017value_parameter\030\006 \003" +
+ "(\01322.org.jetbrains.kotlin.serialization." +
+ "ValueParameter\022A\n\ntype_table\030\036 \001(\0132-.org" +
+ ".jetbrains.kotlin.serialization.TypeTabl",
+ "e\022\027\n\017sinceKotlinInfo\030\037 \001(\005*\005\010d\020\310\001\"\350\003\n\010Pr" +
+ "operty\022\022\n\005flags\030\013 \001(\005:\003518\022\027\n\told_flags\030" +
+ "\001 \001(\005:\0042054\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022=\n\013retur" +
+ "n_type\030\003 \001(\0132(.org.jetbrains.kotlin.seri" +
+ "alization.Type\022\026\n\016return_type_id\030\t \001(\005\022I" +
+ "\n\016type_parameter\030\004 \003(\01321.org.jetbrains.k" +
+ "otlin.serialization.TypeParameter\022?\n\rrec" +
+ "eiver_type\030\005 \001(\0132(.org.jetbrains.kotlin." +
+ "serialization.Type\022\030\n\020receiver_type_id\030\n" +
+ " \001(\005\022R\n\026setter_value_parameter\030\006 \001(\01322.o",
+ "rg.jetbrains.kotlin.serialization.ValueP" +
+ "arameter\022\024\n\014getter_flags\030\007 \001(\005\022\024\n\014setter" +
+ "_flags\030\010 \001(\005\022\027\n\017sinceKotlinInfo\030\037 \001(\005*\005\010" +
+ "d\020\310\001\"\355\001\n\016ValueParameter\022\020\n\005flags\030\001 \001(\005:\001" +
+ "0\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0226\n\004type\030\003 \001(\0132(.or" +
+ "g.jetbrains.kotlin.serialization.Type\022\017\n" +
+ "\007type_id\030\005 \001(\005\022E\n\023vararg_element_type\030\004 " +
+ "\001(\0132(.org.jetbrains.kotlin.serialization" +
+ ".Type\022\036\n\026vararg_element_type_id\030\006 \001(\005*\005\010" +
+ "d\020\310\001\"\232\003\n\tTypeAlias\022\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004",
+ "name\030\002 \002(\005B\004\210\265\030\001\022I\n\016type_parameter\030\003 \003(\013" +
+ "21.org.jetbrains.kotlin.serialization.Ty" +
+ "peParameter\022A\n\017underlying_type\030\004 \001(\0132(.o" +
+ "rg.jetbrains.kotlin.serialization.Type\022\032" +
+ "\n\022underlying_type_id\030\005 \001(\005\022?\n\rexpanded_t" +
+ "ype\030\006 \001(\0132(.org.jetbrains.kotlin.seriali" +
+ "zation.Type\022\030\n\020expanded_type_id\030\007 \001(\005\022B\n" +
+ "\nannotation\030\010 \003(\0132..org.jetbrains.kotlin" +
+ ".serialization.Annotation\022\027\n\017sinceKotlin" +
+ "Info\030\037 \001(\005*\005\010d\020\310\001\"&\n\tEnumEntry\022\022\n\004name\030\001",
+ " \001(\005B\004\210\265\030\001*\005\010d\020\310\001\"\341\001\n\017SinceKotlinInfo\022\017\n" +
+ "\007version\030\001 \001(\005\022\024\n\014version_full\030\002 \001(\005\022O\n\005" +
+ "level\030\003 \001(\01629.org.jetbrains.kotlin.seria" +
+ "lization.SinceKotlinInfo.Level:\005ERROR\022\022\n" +
+ "\nerror_code\030\004 \001(\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001" +
+ "\"+\n\005Level\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HID" +
+ "DEN\020\002\"Y\n\024SinceKotlinInfoTable\022A\n\004info\030\001 " +
+ "\003(\01323.org.jetbrains.kotlin.serialization" +
+ ".SinceKotlinInfo*9\n\010Modality\022\t\n\005FINAL\020\000\022" +
+ "\010\n\004OPEN\020\001\022\014\n\010ABSTRACT\020\002\022\n\n\006SEALED\020\003*b\n\nV",
+ "isibility\022\014\n\010INTERNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\t" +
+ "PROTECTED\020\002\022\n\n\006PUBLIC\020\003\022\023\n\017PRIVATE_TO_TH" +
+ "IS\020\004\022\t\n\005LOCAL\020\005*Q\n\nMemberKind\022\017\n\013DECLARA" +
+ "TION\020\000\022\021\n\rFAKE_OVERRIDE\020\001\022\016\n\nDELEGATION\020" +
+ "\002\022\017\n\013SYNTHESIZED\020\003B\017B\rDebugProtoBuf"
};
org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -27465,7 +27631,7 @@ public final class DebugProtoBuf {
internal_static_org_jetbrains_kotlin_serialization_Class_fieldAccessorTable = new
org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_jetbrains_kotlin_serialization_Class_descriptor,
- new java.lang.String[] { "Flags", "FqName", "CompanionObjectName", "TypeParameter", "Supertype", "SupertypeId", "NestedClassName", "Constructor", "Function", "Property", "TypeAlias", "EnumEntry", "TypeTable", "SinceKotlinInfo", "SinceKotlinInfoTable", });
+ new java.lang.String[] { "Flags", "FqName", "CompanionObjectName", "TypeParameter", "Supertype", "SupertypeId", "NestedClassName", "Constructor", "Function", "Property", "TypeAlias", "EnumEntry", "SealedSubclassFqName", "TypeTable", "SinceKotlinInfo", "SinceKotlinInfoTable", });
internal_static_org_jetbrains_kotlin_serialization_Package_descriptor =
getDescriptor().getMessageTypes().get(6);
internal_static_org_jetbrains_kotlin_serialization_Package_fieldAccessorTable = new
@@ -27541,6 +27707,7 @@ public final class DebugProtoBuf {
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.fqNameIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
+ registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.fqNameIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
registry.add(org.jetbrains.kotlin.serialization.DebugExtOptionsProtoBuf.nameIdInTable);
diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt
index 4ad03bce4ca..7f9c61f4341 100644
--- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt
+++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry
import org.jetbrains.kotlin.resolve.MemberComparator
import org.jetbrains.kotlin.resolve.constants.NullValue
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
+import org.jetbrains.kotlin.resolve.descriptorUtil.classId
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.utils.Interner
import java.io.ByteArrayOutputStream
@@ -116,6 +117,10 @@ class DescriptorSerializer private constructor(
}
}
+ for (sealedSubclass in classDescriptor.sealedSubclasses) {
+ builder.addSealedSubclassFqName(getClassifierId(sealedSubclass))
+ }
+
val companionObjectDescriptor = classDescriptor.companionObjectDescriptor
if (companionObjectDescriptor != null) {
builder.companionObjectName = getSimpleNameIndex(companionObjectDescriptor.name)
diff --git a/compiler/testData/compileKotlinAgainstKotlin/sealedClass.kt b/compiler/testData/compileKotlinAgainstKotlin/sealedClass.kt
new file mode 100644
index 00000000000..dff0e486a51
--- /dev/null
+++ b/compiler/testData/compileKotlinAgainstKotlin/sealedClass.kt
@@ -0,0 +1,38 @@
+// FILE: A.kt
+
+package a
+
+sealed class Empty
+
+sealed class OnlyNested {
+ class Nested : OnlyNested()
+}
+
+sealed class NestedAndTopLevel {
+ class Nested : NestedAndTopLevel()
+}
+class TopLevel : NestedAndTopLevel()
+
+// FILE: B.kt
+
+import a.*
+
+// This test checks that we correctly load subclasses of a compiled sealed class from binaries.
+// It's not a diagnostic test because there are no diagnostic tests where resolution is performed against compiled Kotlin binaries
+
+fun empty(e: Empty): String = when (e) {
+ else -> "1"
+}
+
+fun onlyNested(on: OnlyNested): String = when (on) {
+ is OnlyNested.Nested -> "2"
+}
+
+fun nestedAndTopLevel(natl: NestedAndTopLevel): String = when (natl) {
+ is NestedAndTopLevel.Nested -> "3"
+ is TopLevel -> "4"
+}
+
+fun box(): String {
+ return "OK"
+}
diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java
index 66b56cfd526..73cf7c74e51 100644
--- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java
+++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java
@@ -204,6 +204,12 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
doTest(fileName);
}
+ @TestMetadata("sealedClass.kt")
+ public void testSealedClass() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/sealedClass.kt");
+ doTest(fileName);
+ }
+
@TestMetadata("secondaryConstructors.kt")
public void testSecondaryConstructors() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/secondaryConstructors.kt");
diff --git a/core/deserialization/src/descriptors.proto b/core/deserialization/src/descriptors.proto
index 0babf1dcbb2..db5734011cb 100644
--- a/core/deserialization/src/descriptors.proto
+++ b/core/deserialization/src/descriptors.proto
@@ -206,6 +206,8 @@ message Class {
repeated EnumEntry enum_entry = 13;
+ repeated int32 sealed_subclass_fq_name = 16 [packed = true, (fq_name_id_in_table) = true];
+
optional TypeTable type_table = 30;
// Index into the SinceKotlinInfoTable
diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java b/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java
index 23eee30e874..bd32a817f9c 100644
--- a/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java
+++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java
@@ -8095,6 +8095,19 @@ public final class ProtoBuf {
*/
int getEnumEntryCount();
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ java.util.List getSealedSubclassFqNameList();
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ int getSealedSubclassFqNameCount();
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ int getSealedSubclassFqName(int index);
+
/**
* optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
*/
@@ -8294,6 +8307,27 @@ public final class ProtoBuf {
enumEntry_.add(input.readMessage(org.jetbrains.kotlin.serialization.ProtoBuf.EnumEntry.PARSER, extensionRegistry));
break;
}
+ case 128: {
+ if (!((mutable_bitField0_ & 0x00001000) == 0x00001000)) {
+ sealedSubclassFqName_ = new java.util.ArrayList();
+ mutable_bitField0_ |= 0x00001000;
+ }
+ sealedSubclassFqName_.add(input.readInt32());
+ break;
+ }
+ case 130: {
+ int length = input.readRawVarint32();
+ int limit = input.pushLimit(length);
+ if (!((mutable_bitField0_ & 0x00001000) == 0x00001000) && input.getBytesUntilLimit() > 0) {
+ sealedSubclassFqName_ = new java.util.ArrayList();
+ mutable_bitField0_ |= 0x00001000;
+ }
+ while (input.getBytesUntilLimit() > 0) {
+ sealedSubclassFqName_.add(input.readInt32());
+ }
+ input.popLimit(limit);
+ break;
+ }
case 242: {
org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.Builder subBuilder = null;
if (((bitField0_ & 0x00000008) == 0x00000008)) {
@@ -8360,6 +8394,9 @@ public final class ProtoBuf {
if (((mutable_bitField0_ & 0x00000800) == 0x00000800)) {
enumEntry_ = java.util.Collections.unmodifiableList(enumEntry_);
}
+ if (((mutable_bitField0_ & 0x00001000) == 0x00001000)) {
+ sealedSubclassFqName_ = java.util.Collections.unmodifiableList(sealedSubclassFqName_);
+ }
try {
unknownFieldsCodedOutput.flush();
} catch (java.io.IOException e) {
@@ -8849,6 +8886,29 @@ public final class ProtoBuf {
return enumEntry_.get(index);
}
+ public static final int SEALED_SUBCLASS_FQ_NAME_FIELD_NUMBER = 16;
+ private java.util.List sealedSubclassFqName_;
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public java.util.List
+ getSealedSubclassFqNameList() {
+ return sealedSubclassFqName_;
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public int getSealedSubclassFqNameCount() {
+ return sealedSubclassFqName_.size();
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public int getSealedSubclassFqName(int index) {
+ return sealedSubclassFqName_.get(index);
+ }
+ private int sealedSubclassFqNameMemoizedSerializedSize = -1;
+
public static final int TYPE_TABLE_FIELD_NUMBER = 30;
private org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable typeTable_;
/**
@@ -8915,6 +8975,7 @@ public final class ProtoBuf {
property_ = java.util.Collections.emptyList();
typeAlias_ = java.util.Collections.emptyList();
enumEntry_ = java.util.Collections.emptyList();
+ sealedSubclassFqName_ = java.util.Collections.emptyList();
typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance();
sinceKotlinInfo_ = 0;
sinceKotlinInfoTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.SinceKotlinInfoTable.getDefaultInstance();
@@ -9035,6 +9096,13 @@ public final class ProtoBuf {
for (int i = 0; i < enumEntry_.size(); i++) {
output.writeMessage(13, enumEntry_.get(i));
}
+ if (getSealedSubclassFqNameList().size() > 0) {
+ output.writeRawVarint32(130);
+ output.writeRawVarint32(sealedSubclassFqNameMemoizedSerializedSize);
+ }
+ for (int i = 0; i < sealedSubclassFqName_.size(); i++) {
+ output.writeInt32NoTag(sealedSubclassFqName_.get(i));
+ }
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeMessage(30, typeTable_);
}
@@ -9122,6 +9190,20 @@ public final class ProtoBuf {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(13, enumEntry_.get(i));
}
+ {
+ int dataSize = 0;
+ for (int i = 0; i < sealedSubclassFqName_.size(); i++) {
+ dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream
+ .computeInt32SizeNoTag(sealedSubclassFqName_.get(i));
+ }
+ size += dataSize;
+ if (!getSealedSubclassFqNameList().isEmpty()) {
+ size += 2;
+ size += org.jetbrains.kotlin.protobuf.CodedOutputStream
+ .computeInt32SizeNoTag(dataSize);
+ }
+ sealedSubclassFqNameMemoizedSerializedSize = dataSize;
+ }
if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
.computeMessageSize(30, typeTable_);
@@ -9252,12 +9334,14 @@ public final class ProtoBuf {
bitField0_ = (bitField0_ & ~0x00000400);
enumEntry_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000800);
- typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance();
+ sealedSubclassFqName_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00001000);
- sinceKotlinInfo_ = 0;
+ typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00002000);
- sinceKotlinInfoTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.SinceKotlinInfoTable.getDefaultInstance();
+ sinceKotlinInfo_ = 0;
bitField0_ = (bitField0_ & ~0x00004000);
+ sinceKotlinInfoTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.SinceKotlinInfoTable.getDefaultInstance();
+ bitField0_ = (bitField0_ & ~0x00008000);
return this;
}
@@ -9338,15 +9422,20 @@ public final class ProtoBuf {
bitField0_ = (bitField0_ & ~0x00000800);
}
result.enumEntry_ = enumEntry_;
- if (((from_bitField0_ & 0x00001000) == 0x00001000)) {
+ if (((bitField0_ & 0x00001000) == 0x00001000)) {
+ sealedSubclassFqName_ = java.util.Collections.unmodifiableList(sealedSubclassFqName_);
+ bitField0_ = (bitField0_ & ~0x00001000);
+ }
+ result.sealedSubclassFqName_ = sealedSubclassFqName_;
+ if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
to_bitField0_ |= 0x00000008;
}
result.typeTable_ = typeTable_;
- if (((from_bitField0_ & 0x00002000) == 0x00002000)) {
+ if (((from_bitField0_ & 0x00004000) == 0x00004000)) {
to_bitField0_ |= 0x00000010;
}
result.sinceKotlinInfo_ = sinceKotlinInfo_;
- if (((from_bitField0_ & 0x00004000) == 0x00004000)) {
+ if (((from_bitField0_ & 0x00008000) == 0x00008000)) {
to_bitField0_ |= 0x00000020;
}
result.sinceKotlinInfoTable_ = sinceKotlinInfoTable_;
@@ -9454,6 +9543,16 @@ public final class ProtoBuf {
enumEntry_.addAll(other.enumEntry_);
}
+ }
+ if (!other.sealedSubclassFqName_.isEmpty()) {
+ if (sealedSubclassFqName_.isEmpty()) {
+ sealedSubclassFqName_ = other.sealedSubclassFqName_;
+ bitField0_ = (bitField0_ & ~0x00001000);
+ } else {
+ ensureSealedSubclassFqNameIsMutable();
+ sealedSubclassFqName_.addAll(other.sealedSubclassFqName_);
+ }
+
}
if (other.hasTypeTable()) {
mergeTypeTable(other.getTypeTable());
@@ -10688,12 +10787,78 @@ public final class ProtoBuf {
return this;
}
+ private java.util.List sealedSubclassFqName_ = java.util.Collections.emptyList();
+ private void ensureSealedSubclassFqNameIsMutable() {
+ if (!((bitField0_ & 0x00001000) == 0x00001000)) {
+ sealedSubclassFqName_ = new java.util.ArrayList(sealedSubclassFqName_);
+ bitField0_ |= 0x00001000;
+ }
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public java.util.List
+ getSealedSubclassFqNameList() {
+ return java.util.Collections.unmodifiableList(sealedSubclassFqName_);
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public int getSealedSubclassFqNameCount() {
+ return sealedSubclassFqName_.size();
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public int getSealedSubclassFqName(int index) {
+ return sealedSubclassFqName_.get(index);
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public Builder setSealedSubclassFqName(
+ int index, int value) {
+ ensureSealedSubclassFqNameIsMutable();
+ sealedSubclassFqName_.set(index, value);
+
+ return this;
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public Builder addSealedSubclassFqName(int value) {
+ ensureSealedSubclassFqNameIsMutable();
+ sealedSubclassFqName_.add(value);
+
+ return this;
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public Builder addAllSealedSubclassFqName(
+ java.lang.Iterable extends java.lang.Integer> values) {
+ ensureSealedSubclassFqNameIsMutable();
+ org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
+ values, sealedSubclassFqName_);
+
+ return this;
+ }
+ /**
+ * repeated int32 sealed_subclass_fq_name = 16 [packed = true];
+ */
+ public Builder clearSealedSubclassFqName() {
+ sealedSubclassFqName_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00001000);
+
+ return this;
+ }
+
private org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance();
/**
* optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
*/
public boolean hasTypeTable() {
- return ((bitField0_ & 0x00001000) == 0x00001000);
+ return ((bitField0_ & 0x00002000) == 0x00002000);
}
/**
* optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
@@ -10710,7 +10875,7 @@ public final class ProtoBuf {
}
typeTable_ = value;
- bitField0_ |= 0x00001000;
+ bitField0_ |= 0x00002000;
return this;
}
/**
@@ -10720,14 +10885,14 @@ public final class ProtoBuf {
org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.Builder builderForValue) {
typeTable_ = builderForValue.build();
- bitField0_ |= 0x00001000;
+ bitField0_ |= 0x00002000;
return this;
}
/**
* optional .org.jetbrains.kotlin.serialization.TypeTable type_table = 30;
*/
public Builder mergeTypeTable(org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable value) {
- if (((bitField0_ & 0x00001000) == 0x00001000) &&
+ if (((bitField0_ & 0x00002000) == 0x00002000) &&
typeTable_ != org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance()) {
typeTable_ =
org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.newBuilder(typeTable_).mergeFrom(value).buildPartial();
@@ -10735,7 +10900,7 @@ public final class ProtoBuf {
typeTable_ = value;
}
- bitField0_ |= 0x00001000;
+ bitField0_ |= 0x00002000;
return this;
}
/**
@@ -10744,7 +10909,7 @@ public final class ProtoBuf {
public Builder clearTypeTable() {
typeTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.TypeTable.getDefaultInstance();
- bitField0_ = (bitField0_ & ~0x00001000);
+ bitField0_ = (bitField0_ & ~0x00002000);
return this;
}
@@ -10757,7 +10922,7 @@ public final class ProtoBuf {
*
*/
public boolean hasSinceKotlinInfo() {
- return ((bitField0_ & 0x00002000) == 0x00002000);
+ return ((bitField0_ & 0x00004000) == 0x00004000);
}
/**
* optional int32 sinceKotlinInfo = 31;
@@ -10777,7 +10942,7 @@ public final class ProtoBuf {
*
*/
public Builder setSinceKotlinInfo(int value) {
- bitField0_ |= 0x00002000;
+ bitField0_ |= 0x00004000;
sinceKotlinInfo_ = value;
return this;
@@ -10790,7 +10955,7 @@ public final class ProtoBuf {
*
*/
public Builder clearSinceKotlinInfo() {
- bitField0_ = (bitField0_ & ~0x00002000);
+ bitField0_ = (bitField0_ & ~0x00004000);
sinceKotlinInfo_ = 0;
return this;
@@ -10801,7 +10966,7 @@ public final class ProtoBuf {
* optional .org.jetbrains.kotlin.serialization.SinceKotlinInfoTable since_kotlin_info_table = 32;
*/
public boolean hasSinceKotlinInfoTable() {
- return ((bitField0_ & 0x00004000) == 0x00004000);
+ return ((bitField0_ & 0x00008000) == 0x00008000);
}
/**
* optional .org.jetbrains.kotlin.serialization.SinceKotlinInfoTable since_kotlin_info_table = 32;
@@ -10818,7 +10983,7 @@ public final class ProtoBuf {
}
sinceKotlinInfoTable_ = value;
- bitField0_ |= 0x00004000;
+ bitField0_ |= 0x00008000;
return this;
}
/**
@@ -10828,14 +10993,14 @@ public final class ProtoBuf {
org.jetbrains.kotlin.serialization.ProtoBuf.SinceKotlinInfoTable.Builder builderForValue) {
sinceKotlinInfoTable_ = builderForValue.build();
- bitField0_ |= 0x00004000;
+ bitField0_ |= 0x00008000;
return this;
}
/**
* optional .org.jetbrains.kotlin.serialization.SinceKotlinInfoTable since_kotlin_info_table = 32;
*/
public Builder mergeSinceKotlinInfoTable(org.jetbrains.kotlin.serialization.ProtoBuf.SinceKotlinInfoTable value) {
- if (((bitField0_ & 0x00004000) == 0x00004000) &&
+ if (((bitField0_ & 0x00008000) == 0x00008000) &&
sinceKotlinInfoTable_ != org.jetbrains.kotlin.serialization.ProtoBuf.SinceKotlinInfoTable.getDefaultInstance()) {
sinceKotlinInfoTable_ =
org.jetbrains.kotlin.serialization.ProtoBuf.SinceKotlinInfoTable.newBuilder(sinceKotlinInfoTable_).mergeFrom(value).buildPartial();
@@ -10843,7 +11008,7 @@ public final class ProtoBuf {
sinceKotlinInfoTable_ = value;
}
- bitField0_ |= 0x00004000;
+ bitField0_ |= 0x00008000;
return this;
}
/**
@@ -10852,7 +11017,7 @@ public final class ProtoBuf {
public Builder clearSinceKotlinInfoTable() {
sinceKotlinInfoTable_ = org.jetbrains.kotlin.serialization.ProtoBuf.SinceKotlinInfoTable.getDefaultInstance();
- bitField0_ = (bitField0_ & ~0x00004000);
+ bitField0_ = (bitField0_ & ~0x00008000);
return this;
}
diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt
index 1927fb38466..3104f9a8fac 100644
--- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt
+++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt
@@ -150,7 +150,16 @@ class DeserializedClassDescriptor(
name in memberScope.classNames
private fun computeSubclassesForSealedClass(): Collection {
- // TODO: store the list of subclasses to metadata
+ if (modality != Modality.SEALED) return emptyList()
+
+ val fqNames = classProto.sealedSubclassFqNameList
+ if (fqNames.isNotEmpty()) {
+ return fqNames.mapNotNull { index ->
+ c.components.deserializeClass(c.nameResolver.getClassId(index))
+ }
+ }
+
+ // This is needed because classes compiled with Kotlin 1.0 did not contain the sealed_subclass_fq_name field
return computeSealedSubclasses(this)
}