diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmSerializerExtension.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmSerializerExtension.java
index 1d1421a91b4..a0c49b72414 100644
--- a/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmSerializerExtension.java
+++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmSerializerExtension.java
@@ -136,7 +136,7 @@ public class JvmSerializerExtension extends SerializerExtension {
Method syntheticMethod = bindings.get(SYNTHETIC_METHOD_FOR_PROPERTY, descriptor);
JvmProtoBuf.JvmPropertySignature signature = signatureSerializer.propertySignature(
- fieldName, fieldDesc, isStaticInOuter,
+ descriptor, fieldName, fieldDesc, isStaticInOuter,
syntheticMethod != null ? signatureSerializer.methodSignature(null, syntheticMethod) : null,
getterMethod != null ? signatureSerializer.methodSignature(null, getterMethod) : null,
setterMethod != null ? signatureSerializer.methodSignature(null, setterMethod) : null
@@ -201,6 +201,10 @@ public class JvmSerializerExtension extends SerializerExtension {
return !sb.toString().equals(desc);
}
+ private boolean requiresSignature(@NotNull PropertyDescriptor descriptor, @NotNull String desc) {
+ return !desc.equals(mapTypeDefault(descriptor.getType()));
+ }
+
@Nullable
private String mapTypeDefault(@NotNull JetType type) {
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
@@ -226,6 +230,7 @@ public class JvmSerializerExtension extends SerializerExtension {
@NotNull
public JvmProtoBuf.JvmPropertySignature propertySignature(
+ @NotNull PropertyDescriptor descriptor,
@Nullable String fieldName,
@Nullable String fieldDesc,
boolean isStaticInOuter,
@@ -237,7 +242,7 @@ public class JvmSerializerExtension extends SerializerExtension {
if (fieldDesc != null) {
assert fieldName != null : "Field name shouldn't be null when there's a field type: " + fieldDesc;
- signature.setField(fieldSignature(fieldName, fieldDesc, isStaticInOuter));
+ signature.setField(fieldSignature(descriptor, fieldName, fieldDesc, isStaticInOuter));
}
if (syntheticMethod != null) {
@@ -255,10 +260,19 @@ public class JvmSerializerExtension extends SerializerExtension {
}
@NotNull
- public JvmProtoBuf.JvmFieldSignature fieldSignature(@NotNull String name, @NotNull String desc, boolean isStaticInOuter) {
- JvmProtoBuf.JvmFieldSignature.Builder builder = JvmProtoBuf.JvmFieldSignature.newBuilder()
- .setName(stringTable.getStringIndex(name))
- .setDesc(stringTable.getStringIndex(desc));
+ public JvmProtoBuf.JvmFieldSignature fieldSignature(
+ @NotNull PropertyDescriptor descriptor,
+ @NotNull String name,
+ @NotNull String desc,
+ boolean isStaticInOuter
+ ) {
+ JvmProtoBuf.JvmFieldSignature.Builder builder = JvmProtoBuf.JvmFieldSignature.newBuilder();
+ if (!descriptor.getName().asString().equals(name)) {
+ builder.setName(stringTable.getStringIndex(name));
+ }
+ if (requiresSignature(descriptor, desc)) {
+ builder.setDesc(stringTable.getStringIndex(desc));
+ }
if (isStaticInOuter) {
builder.setIsStaticInOuter(true);
}
diff --git a/compiler/tests/org/jetbrains/kotlin/serialization/jvm/DebugJvmProtoBuf.java b/compiler/tests/org/jetbrains/kotlin/serialization/jvm/DebugJvmProtoBuf.java
index 4860be4957e..e03018bcafb 100644
--- a/compiler/tests/org/jetbrains/kotlin/serialization/jvm/DebugJvmProtoBuf.java
+++ b/compiler/tests/org/jetbrains/kotlin/serialization/jvm/DebugJvmProtoBuf.java
@@ -2673,19 +2673,19 @@ public final class DebugJvmProtoBuf {
public interface JvmFieldSignatureOrBuilder
extends com.google.protobuf.MessageOrBuilder {
- // required int32 name = 1;
+ // optional int32 name = 1;
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
boolean hasName();
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
int getName();
- // required int32 desc = 2;
+ // optional int32 desc = 2;
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2693,7 +2693,7 @@ public final class DebugJvmProtoBuf {
*/
boolean hasDesc();
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2827,27 +2827,27 @@ public final class DebugJvmProtoBuf {
}
private int bitField0_;
- // required int32 name = 1;
+ // optional int32 name = 1;
public static final int NAME_FIELD_NUMBER = 1;
private int name_;
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public boolean hasName() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public int getName() {
return name_;
}
- // required int32 desc = 2;
+ // optional int32 desc = 2;
public static final int DESC_FIELD_NUMBER = 2;
private int desc_;
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2857,7 +2857,7 @@ public final class DebugJvmProtoBuf {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2903,14 +2903,6 @@ public final class DebugJvmProtoBuf {
byte isInitialized = memoizedIsInitialized;
if (isInitialized != -1) return isInitialized == 1;
- if (!hasName()) {
- memoizedIsInitialized = 0;
- return false;
- }
- if (!hasDesc()) {
- memoizedIsInitialized = 0;
- return false;
- }
memoizedIsInitialized = 1;
return true;
}
@@ -3140,14 +3132,6 @@ public final class DebugJvmProtoBuf {
}
public final boolean isInitialized() {
- if (!hasName()) {
-
- return false;
- }
- if (!hasDesc()) {
-
- return false;
- }
return true;
}
@@ -3170,22 +3154,22 @@ public final class DebugJvmProtoBuf {
}
private int bitField0_;
- // required int32 name = 1;
+ // optional int32 name = 1;
private int name_ ;
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public boolean hasName() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public int getName() {
return name_;
}
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public Builder setName(int value) {
bitField0_ |= 0x00000001;
@@ -3194,7 +3178,7 @@ public final class DebugJvmProtoBuf {
return this;
}
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public Builder clearName() {
bitField0_ = (bitField0_ & ~0x00000001);
@@ -3203,10 +3187,10 @@ public final class DebugJvmProtoBuf {
return this;
}
- // required int32 desc = 2;
+ // optional int32 desc = 2;
private int desc_ ;
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -3216,7 +3200,7 @@ public final class DebugJvmProtoBuf {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -3226,7 +3210,7 @@ public final class DebugJvmProtoBuf {
return desc_;
}
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -3239,7 +3223,7 @@ public final class DebugJvmProtoBuf {
return this;
}
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -3641,12 +3625,6 @@ public final class DebugJvmProtoBuf {
byte isInitialized = memoizedIsInitialized;
if (isInitialized != -1) return isInitialized == 1;
- if (hasField()) {
- if (!getField().isInitialized()) {
- memoizedIsInitialized = 0;
- return false;
- }
- }
memoizedIsInitialized = 1;
return true;
}
@@ -3928,12 +3906,6 @@ public final class DebugJvmProtoBuf {
}
public final boolean isInitialized() {
- if (hasField()) {
- if (!getField().isInitialized()) {
-
- return false;
- }
- }
return true;
}
@@ -4621,8 +4593,8 @@ public final class DebugJvmProtoBuf {
"\022\030\n\024INTERNAL_TO_CLASS_ID\020\001\022\024\n\020DESC_TO_CL" +
"ASS_ID\020\002\"<\n\022JvmMethodSignature\022\022\n\004name\030\001" +
" \001(\005B\004\230\265\030\001\022\022\n\004desc\030\002 \001(\005B\004\230\265\030\001\"^\n\021JvmFie" +
- "ldSignature\022\022\n\004name\030\001 \002(\005B\004\230\265\030\001\022\022\n\004desc\030" +
- "\002 \002(\005B\004\230\265\030\001\022!\n\022is_static_in_outer\030\003 \001(\010:" +
+ "ldSignature\022\022\n\004name\030\001 \001(\005B\004\230\265\030\001\022\022\n\004desc\030" +
+ "\002 \001(\005B\004\230\265\030\001\022!\n\022is_static_in_outer\030\003 \001(\010:" +
"\005false\"\316\002\n\024JvmPropertySignature\022H\n\005field",
"\030\001 \001(\01329.org.jetbrains.kotlin.serializat" +
"ion.jvm.JvmFieldSignature\022T\n\020synthetic_m" +
diff --git a/core/descriptor.loader.java/src/jvm_descriptors.proto b/core/descriptor.loader.java/src/jvm_descriptors.proto
index 71694ebba75..6945455bc06 100644
--- a/core/descriptor.loader.java/src/jvm_descriptors.proto
+++ b/core/descriptor.loader.java/src/jvm_descriptors.proto
@@ -69,10 +69,10 @@ message JvmMethodSignature {
}
message JvmFieldSignature {
- required int32 name = 1 [(string_id_in_table) = true];
+ optional int32 name = 1 [(string_id_in_table) = true];
// JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
- required int32 desc = 2 [(string_id_in_table) = true];
+ optional int32 desc = 2 [(string_id_in_table) = true];
// True iff this field is a backing field for a companion object and is really present as a static
// field in the outer class, not as an instance field here
diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt
index 2e4b7874bb9..24da49d432a 100644
--- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt
+++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt
@@ -286,11 +286,9 @@ public abstract class AbstractBinaryClassAnnotationAndConstantLoaderrequired int32 name = 1;
+ * optional int32 name = 1;
*/
boolean hasName();
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
int getName();
- // required int32 desc = 2;
+ // optional int32 desc = 2;
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2326,7 +2326,7 @@ public final class JvmProtoBuf {
*/
boolean hasDesc();
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2439,27 +2439,27 @@ public final class JvmProtoBuf {
}
private int bitField0_;
- // required int32 name = 1;
+ // optional int32 name = 1;
public static final int NAME_FIELD_NUMBER = 1;
private int name_;
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public boolean hasName() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public int getName() {
return name_;
}
- // required int32 desc = 2;
+ // optional int32 desc = 2;
public static final int DESC_FIELD_NUMBER = 2;
private int desc_;
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2469,7 +2469,7 @@ public final class JvmProtoBuf {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2515,14 +2515,6 @@ public final class JvmProtoBuf {
byte isInitialized = memoizedIsInitialized;
if (isInitialized != -1) return isInitialized == 1;
- if (!hasName()) {
- memoizedIsInitialized = 0;
- return false;
- }
- if (!hasDesc()) {
- memoizedIsInitialized = 0;
- return false;
- }
memoizedIsInitialized = 1;
return true;
}
@@ -2710,14 +2702,6 @@ public final class JvmProtoBuf {
}
public final boolean isInitialized() {
- if (!hasName()) {
-
- return false;
- }
- if (!hasDesc()) {
-
- return false;
- }
return true;
}
@@ -2740,22 +2724,22 @@ public final class JvmProtoBuf {
}
private int bitField0_;
- // required int32 name = 1;
+ // optional int32 name = 1;
private int name_ ;
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public boolean hasName() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public int getName() {
return name_;
}
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public Builder setName(int value) {
bitField0_ |= 0x00000001;
@@ -2764,7 +2748,7 @@ public final class JvmProtoBuf {
return this;
}
/**
- * required int32 name = 1;
+ * optional int32 name = 1;
*/
public Builder clearName() {
bitField0_ = (bitField0_ & ~0x00000001);
@@ -2773,10 +2757,10 @@ public final class JvmProtoBuf {
return this;
}
- // required int32 desc = 2;
+ // optional int32 desc = 2;
private int desc_ ;
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2786,7 +2770,7 @@ public final class JvmProtoBuf {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2796,7 +2780,7 @@ public final class JvmProtoBuf {
return desc_;
}
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -2809,7 +2793,7 @@ public final class JvmProtoBuf {
return this;
}
/**
- * required int32 desc = 2;
+ * optional int32 desc = 2;
*
*
* JVM descriptor of the field type, e.g. 'Ljava/lang/String;'
@@ -3142,12 +3126,6 @@ public final class JvmProtoBuf {
byte isInitialized = memoizedIsInitialized;
if (isInitialized != -1) return isInitialized == 1;
- if (hasField()) {
- if (!getField().isInitialized()) {
- memoizedIsInitialized = 0;
- return false;
- }
- }
memoizedIsInitialized = 1;
return true;
}
@@ -3351,12 +3329,6 @@ public final class JvmProtoBuf {
}
public final boolean isInitialized() {
- if (hasField()) {
- if (!getField().isInitialized()) {
-
- return false;
- }
- }
return true;
}
diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil.kt
index 7f261c7ca8e..670c1c075c9 100644
--- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil.kt
+++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/serialization/jvm/JvmProtoBufUtil.kt
@@ -93,6 +93,22 @@ public object JvmProtoBufUtil {
return "" + desc
}
+ fun getJvmFieldSignature(proto: ProtoBuf.Property, nameResolver: NameResolver): PropertySignature? {
+ val signature =
+ if (proto.hasExtension(JvmProtoBuf.propertySignature)) proto.getExtension(JvmProtoBuf.propertySignature) else return null
+ val field =
+ if (signature.hasField()) signature.field else null
+
+ val name = if (field != null && field.hasName()) field.name else proto.name
+ val desc =
+ if (field != null && field.hasDesc()) nameResolver.getString(field.desc)
+ else mapTypeDefault(proto.returnType, nameResolver) ?: return null
+
+ return PropertySignature(nameResolver.getString(name), desc)
+ }
+
+ data class PropertySignature(val name: String, val desc: String)
+
private fun mapTypeDefault(type: ProtoBuf.Type, nameResolver: NameResolver): String? {
return if (type.hasClassName()) mapClassIdDefault(nameResolver.getClassId(type.className)) else null
}
diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt
index 2154a09af08..dc9bdc1bd16 100644
--- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt
+++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt
@@ -17,6 +17,7 @@
package kotlin.reflect.jvm.internal
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
+import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
import java.lang.reflect.Field
import kotlin.reflect.jvm.internal.JvmPropertySignature.JavaField
import kotlin.reflect.jvm.internal.JvmPropertySignature.KotlinProperty
@@ -46,8 +47,9 @@ internal abstract class DescriptorBasedProperty protected constructor(
val jvmSignature = RuntimeTypeMapper.mapPropertySignature(descriptor)
when (jvmSignature) {
is KotlinProperty -> {
- if (!jvmSignature.signature.hasField()) null
- else container.findFieldBySignature(jvmSignature.proto, jvmSignature.signature.field, jvmSignature.nameResolver)
+ JvmProtoBufUtil.getJvmFieldSignature(jvmSignature.proto, jvmSignature.nameResolver)?.let {
+ container.findFieldBySignature(jvmSignature.proto, jvmSignature.nameResolver, it.name)
+ }
}
is JavaField -> jvmSignature.field
}
diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt
index a56d38f39cb..bf05b74c2e7 100644
--- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt
+++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt
@@ -240,17 +240,14 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain
// TODO: check resulting field's type
fun findFieldBySignature(
proto: ProtoBuf.Property,
- signature: JvmProtoBuf.JvmFieldSignature,
- nameResolver: NameResolver
+ nameResolver: NameResolver,
+ name: String
): Field? {
- val name = nameResolver.getString(signature.getName())
-
- val owner =
- implClassForCallable(nameResolver, proto) ?:
- if (signature.getIsStaticInOuter()) {
- jClass.getEnclosingClass() ?: throw KotlinReflectionInternalError("Inconsistent metadata for field $name in $jClass")
- }
- else jClass
+ val owner = implClassForCallable(nameResolver, proto) ?:
+ if (proto.hasExtension(JvmProtoBuf.propertySignature) &&
+ proto.getExtension(JvmProtoBuf.propertySignature).let { it.hasField() && it.field.getIsStaticInOuter() }) {
+ jClass.enclosingClass ?: throw KotlinReflectionInternalError("Inconsistent metadata for field $name in $jClass")
+ } else jClass
return try {
owner.getDeclaredField(name)
diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt
index 3dd5ae12754..e5293b616e7 100644
--- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt
+++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt
@@ -92,6 +92,7 @@ internal sealed class JvmPropertySignature {
abstract fun asString(): String
class KotlinProperty(
+ val descriptor: PropertyDescriptor,
val proto: ProtoBuf.Property,
val signature: JvmProtoBuf.JvmPropertySignature,
val nameResolver: NameResolver
@@ -103,9 +104,10 @@ internal sealed class JvmPropertySignature {
string = nameResolver.getString(signature.getter.name) + nameResolver.getString(signature.getter.desc)
}
else {
- string = JvmAbi.getterName(nameResolver.getString(signature.field.name)) +
- "()" +
- nameResolver.getString(signature.field.desc)
+ val (name, desc) =
+ JvmProtoBufUtil.getJvmFieldSignature(proto, nameResolver) ?:
+ throw KotlinReflectionInternalError("No field signature for property: $descriptor")
+ string = JvmAbi.getterName(name) + "()" + desc
}
}
@@ -170,7 +172,9 @@ internal object RuntimeTypeMapper {
if (!proto.hasExtension(JvmProtoBuf.propertySignature)) {
throw KotlinReflectionInternalError("No metadata found for $property")
}
- return JvmPropertySignature.KotlinProperty(proto, proto.getExtension(JvmProtoBuf.propertySignature), property.nameResolver)
+ return JvmPropertySignature.KotlinProperty(
+ property, proto, proto.getExtension(JvmProtoBuf.propertySignature), property.nameResolver
+ )
}
else if (property is JavaPropertyDescriptor) {
val field = ((property.source as? JavaSourceElement)?.javaElement as? ReflectJavaField)?.member ?:
diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt
index fb2c9754a14..597ba7dcbfb 100644
--- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt
+++ b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/ProtoCompareGenerated.kt
@@ -390,9 +390,15 @@ open class ProtoCompareGenerated(public val oldNameResolver: NameResolver, publi
}
open fun checkEquals(old: JvmProtoBuf.JvmFieldSignature, new: JvmProtoBuf.JvmFieldSignature): Boolean {
- if (!checkStringEquals(old.name, new.name)) return false
+ if (old.hasName() != new.hasName()) return false
+ if (old.hasName()) {
+ if (!checkStringEquals(old.name, new.name)) return false
+ }
- if (!checkStringEquals(old.desc, new.desc)) return false
+ if (old.hasDesc() != new.hasDesc()) return false
+ if (old.hasDesc()) {
+ if (!checkStringEquals(old.desc, new.desc)) return false
+ }
if (old.hasIsStaticInOuter() != new.hasIsStaticInOuter()) return false
if (old.hasIsStaticInOuter()) {
@@ -962,9 +968,13 @@ public fun ProtoBuf.Annotation.Argument.hashCode(stringIndexes: (Int) -> Int, fq
public fun JvmProtoBuf.JvmFieldSignature.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int): Int {
var hashCode = 1
- hashCode = 31 * hashCode + stringIndexes(name)
+ if (hasName()) {
+ hashCode = 31 * hashCode + stringIndexes(name)
+ }
- hashCode = 31 * hashCode + stringIndexes(desc)
+ if (hasDesc()) {
+ hashCode = 31 * hashCode + stringIndexes(desc)
+ }
if (hasIsStaticInOuter()) {
hashCode = 31 * hashCode + isStaticInOuter.hashCode()