[IR] Generify lowerings
#KT-1179
This commit is contained in:
committed by
teamcity
parent
22b2554368
commit
282ab398c6
@@ -201,6 +201,11 @@ open class ProtoCompareGenerated(
|
||||
if (!checkEquals(oldTypeTable.getType(old.inlineClassUnderlyingTypeId), newTypeTable.getType(new.inlineClassUnderlyingTypeId))) return false
|
||||
}
|
||||
|
||||
if (old.hasMultiFieldValueClassRepresentation() != new.hasMultiFieldValueClassRepresentation()) return false
|
||||
if (old.hasMultiFieldValueClassRepresentation()) {
|
||||
if (!checkEquals(old.multiFieldValueClassRepresentation, new.multiFieldValueClassRepresentation)) return false
|
||||
}
|
||||
|
||||
if (!checkEqualsClassVersionRequirement(old, new)) return false
|
||||
|
||||
if (old.hasVersionRequirementTable() != new.hasVersionRequirementTable()) return false
|
||||
@@ -290,6 +295,7 @@ open class ProtoCompareGenerated(
|
||||
INLINE_CLASS_UNDERLYING_PROPERTY_NAME,
|
||||
INLINE_CLASS_UNDERLYING_TYPE,
|
||||
INLINE_CLASS_UNDERLYING_TYPE_ID,
|
||||
MULTI_FIELD_VALUE_CLASS_REPRESENTATION,
|
||||
VERSION_REQUIREMENT_LIST,
|
||||
VERSION_REQUIREMENT_TABLE,
|
||||
JVM_EXT_CLASS_MODULE_NAME,
|
||||
@@ -357,6 +363,11 @@ open class ProtoCompareGenerated(
|
||||
if (!checkEquals(oldTypeTable.getType(old.inlineClassUnderlyingTypeId), newTypeTable.getType(new.inlineClassUnderlyingTypeId))) result.add(ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE_ID)
|
||||
}
|
||||
|
||||
if (old.hasMultiFieldValueClassRepresentation() != new.hasMultiFieldValueClassRepresentation()) result.add(ProtoBufClassKind.MULTI_FIELD_VALUE_CLASS_REPRESENTATION)
|
||||
if (old.hasMultiFieldValueClassRepresentation()) {
|
||||
if (!checkEquals(old.multiFieldValueClassRepresentation, new.multiFieldValueClassRepresentation)) result.add(ProtoBufClassKind.MULTI_FIELD_VALUE_CLASS_REPRESENTATION)
|
||||
}
|
||||
|
||||
if (!checkEqualsClassVersionRequirement(old, new)) result.add(ProtoBufClassKind.VERSION_REQUIREMENT_LIST)
|
||||
|
||||
if (old.hasVersionRequirementTable() != new.hasVersionRequirementTable()) result.add(ProtoBufClassKind.VERSION_REQUIREMENT_TABLE)
|
||||
@@ -1015,6 +1026,12 @@ open class ProtoCompareGenerated(
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEquals(old: ProtoBuf.Class.MultiFieldValueClassRepresentation, new: ProtoBuf.Class.MultiFieldValueClassRepresentation): Boolean {
|
||||
if (!checkEqualsClassMultiFieldValueClassRepresentationProperty(old, new)) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEquals(old: ProtoBuf.Annotation, new: ProtoBuf.Annotation): Boolean {
|
||||
if (!checkClassIdEquals(old.id, new.id)) return false
|
||||
|
||||
@@ -1239,6 +1256,22 @@ open class ProtoCompareGenerated(
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEquals(old: ProtoBuf.Class.MultiFieldValueClassRepresentation.MultiFieldValueClassProperty, new: ProtoBuf.Class.MultiFieldValueClassRepresentation.MultiFieldValueClassProperty): Boolean {
|
||||
if (old.name != new.name) return false
|
||||
|
||||
if (old.hasType() != new.hasType()) return false
|
||||
if (old.hasType()) {
|
||||
if (!checkEquals(old.type, new.type)) return false
|
||||
}
|
||||
|
||||
if (old.hasTypeId() != new.hasTypeId()) return false
|
||||
if (old.hasTypeId()) {
|
||||
if (old.typeId != new.typeId) return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEquals(old: ProtoBuf.Annotation.Argument, new: ProtoBuf.Annotation.Argument): Boolean {
|
||||
if (!checkStringEquals(old.nameId, new.nameId)) return false
|
||||
|
||||
@@ -1655,6 +1688,16 @@ open class ProtoCompareGenerated(
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEqualsClassMultiFieldValueClassRepresentationProperty(old: ProtoBuf.Class.MultiFieldValueClassRepresentation, new: ProtoBuf.Class.MultiFieldValueClassRepresentation): Boolean {
|
||||
if (old.propertyCount != new.propertyCount) return false
|
||||
|
||||
for(i in 0..old.propertyCount - 1) {
|
||||
if (!checkEquals(old.getProperty(i), new.getProperty(i))) return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
open fun checkEqualsAnnotationArgument(old: ProtoBuf.Annotation, new: ProtoBuf.Annotation): Boolean {
|
||||
if (old.argumentCount != new.argumentCount) return false
|
||||
|
||||
@@ -1864,6 +1907,10 @@ fun ProtoBuf.Class.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) ->
|
||||
hashCode = 31 * hashCode + typeById(inlineClassUnderlyingTypeId).hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
if (hasMultiFieldValueClassRepresentation()) {
|
||||
hashCode = 31 * hashCode + multiFieldValueClassRepresentation.hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
for(i in 0..versionRequirementCount - 1) {
|
||||
hashCode = 31 * hashCode + getVersionRequirement(i)
|
||||
}
|
||||
@@ -2365,6 +2412,16 @@ fun ProtoBuf.EnumEntry.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int
|
||||
return hashCode
|
||||
}
|
||||
|
||||
fun ProtoBuf.Class.MultiFieldValueClassRepresentation.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int, typeById: (Int) -> ProtoBuf.Type): Int {
|
||||
var hashCode = 1
|
||||
|
||||
for(i in 0..propertyCount - 1) {
|
||||
hashCode = 31 * hashCode + getProperty(i).hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
return hashCode
|
||||
}
|
||||
|
||||
fun ProtoBuf.Annotation.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int, typeById: (Int) -> ProtoBuf.Type): Int {
|
||||
var hashCode = 1
|
||||
|
||||
@@ -2565,6 +2622,22 @@ fun ProtoBuf.Type.Argument.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes:
|
||||
return hashCode
|
||||
}
|
||||
|
||||
fun ProtoBuf.Class.MultiFieldValueClassRepresentation.MultiFieldValueClassProperty.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int, typeById: (Int) -> ProtoBuf.Type): Int {
|
||||
var hashCode = 1
|
||||
|
||||
hashCode = 31 * hashCode + name
|
||||
|
||||
if (hasType()) {
|
||||
hashCode = 31 * hashCode + type.hashCode(stringIndexes, fqNameIndexes, typeById)
|
||||
}
|
||||
|
||||
if (hasTypeId()) {
|
||||
hashCode = 31 * hashCode + typeId
|
||||
}
|
||||
|
||||
return hashCode
|
||||
}
|
||||
|
||||
fun ProtoBuf.Annotation.Argument.hashCode(stringIndexes: (Int) -> Int, fqNameIndexes: (Int) -> Int, typeById: (Int) -> ProtoBuf.Type): Int {
|
||||
var hashCode = 1
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.protobuf.MessageLite
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptorVisibility
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
||||
import java.util.*
|
||||
|
||||
data class Difference(
|
||||
val isClassAffected: Boolean = false,
|
||||
@@ -292,7 +291,8 @@ class DifferenceCalculatorForClass(
|
||||
}
|
||||
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_PROPERTY_NAME,
|
||||
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE,
|
||||
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE_ID -> {
|
||||
ProtoBufClassKind.INLINE_CLASS_UNDERLYING_TYPE_ID,
|
||||
ProtoBufClassKind.MULTI_FIELD_VALUE_CLASS_REPRESENTATION -> {
|
||||
isClassAffected = true
|
||||
}
|
||||
ProtoBufClassKind.CONTEXT_RECEIVER_TYPE_LIST,
|
||||
|
||||
Reference in New Issue
Block a user