From 2000ea5dee605026acec2d26632afc1cf53360b9 Mon Sep 17 00:00:00 2001 From: Alexander Sysoev Date: Tue, 19 Aug 2025 00:04:15 +0200 Subject: [PATCH 1/5] Fixed some bugs in conformance --- .../protobuf/kotlin/_rpc_internal/Any.kt | 3 +- .../protobuf/kotlin/_rpc_internal/Api.kt | 9 +- .../protobuf/kotlin/_rpc_internal/Duration.kt | 3 +- .../protobuf/kotlin/_rpc_internal/Empty.kt | 3 +- .../kotlin/_rpc_internal/FieldMask.kt | 3 +- .../kotlin/_rpc_internal/SourceContext.kt | 3 +- .../protobuf/kotlin/_rpc_internal/Struct.kt | 11 +- .../kotlin/_rpc_internal/Timestamp.kt | 3 +- .../protobuf/kotlin/_rpc_internal/Type.kt | 15 +- .../protobuf/kotlin/_rpc_internal/Wrappers.kt | 27 +- .../rpc/protobuf/internal/WireDecoder.kt | 4 + .../kotlinx/rpc/protobuf/internal/WireSize.kt | 24 +- .../rpc/protobuf/internal/WireEncoder.jvm.kt | 6 +- .../protobuf/internal/WireEncoder.native.kt | 6 +- .../rpc/protoc/gen/core/model/FieldType.kt | 1 + .../ModelToProtobufKotlinCommonGenerator.kt | 33 +- .../conformance/_rpc_internal/Conformance.kt | 15 +- .../TestMessagesProto3Editions.kt | 312 ++++++++++++++++-- .../_rpc_internal/TestMessagesProto3.kt | 312 ++++++++++++++++-- 19 files changed, 666 insertions(+), 127 deletions(-) diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt index 61f9897aa..b533bbbfa 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt @@ -30,7 +30,6 @@ public class AnyInternal: com.google.protobuf.kotlin.Any, kotlinx.rpc.protobuf.i kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.AnyInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -81,6 +80,8 @@ public fun com.google.protobuf.kotlin.AnyInternal.Companion.decodeWith(msg: com. } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.AnyInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt index 8fd59f481..11bba50de 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt @@ -39,7 +39,6 @@ public class ApiInternal: com.google.protobuf.kotlin.Api, kotlinx.rpc.protobuf.i kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.ApiInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -79,7 +78,6 @@ public class MethodInternal: com.google.protobuf.kotlin.Method, kotlinx.rpc.prot kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.MethodInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -114,7 +112,6 @@ public class MixinInternal: com.google.protobuf.kotlin.Mixin, kotlinx.rpc.protob kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.MixinInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -248,6 +245,8 @@ public fun com.google.protobuf.kotlin.ApiInternal.Companion.decodeWith(msg: com. } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.ApiInternal.computeSize(): Int { @@ -370,6 +369,8 @@ public fun com.google.protobuf.kotlin.MethodInternal.Companion.decodeWith(msg: c } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.MethodInternal.computeSize(): Int { @@ -445,6 +446,8 @@ public fun com.google.protobuf.kotlin.MixinInternal.Companion.decodeWith(msg: co } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.MixinInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt index a21fd44ae..d651a2788 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt @@ -30,7 +30,6 @@ public class DurationInternal: com.google.protobuf.kotlin.Duration, kotlinx.rpc. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.DurationInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -81,6 +80,8 @@ public fun com.google.protobuf.kotlin.DurationInternal.Companion.decodeWith(msg: } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.DurationInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt index 710388e37..319398332 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt @@ -27,7 +27,6 @@ public class EmptyInternal: com.google.protobuf.kotlin.Empty, kotlinx.rpc.protob kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.EmptyInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -64,6 +63,8 @@ public fun com.google.protobuf.kotlin.EmptyInternal.Companion.decodeWith(msg: co } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.EmptyInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt index cb0235951..6d5397459 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt @@ -29,7 +29,6 @@ public class FieldMaskInternal: com.google.protobuf.kotlin.FieldMask, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.FieldMaskInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -75,6 +74,8 @@ public fun com.google.protobuf.kotlin.FieldMaskInternal.Companion.decodeWith(msg } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.FieldMaskInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt index 4c79763a7..3dab051aa 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt @@ -29,7 +29,6 @@ public class SourceContextInternal: com.google.protobuf.kotlin.SourceContext, ko kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.SourceContextInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -72,6 +71,8 @@ public fun com.google.protobuf.kotlin.SourceContextInternal.Companion.decodeWith } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.SourceContextInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt index b9a7eb645..3bf04d436 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt @@ -44,7 +44,6 @@ public class StructInternal: com.google.protobuf.kotlin.Struct, kotlinx.rpc.prot kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.StructInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -78,7 +77,6 @@ public class ValueInternal: com.google.protobuf.kotlin.Value, kotlinx.rpc.protob kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.ValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -112,7 +110,6 @@ public class ListValueInternal: com.google.protobuf.kotlin.ListValue, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.ListValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -181,6 +178,8 @@ public fun com.google.protobuf.kotlin.StructInternal.Companion.decodeWith(msg: c } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.StructInternal.computeSize(): Int { @@ -293,6 +292,8 @@ public fun com.google.protobuf.kotlin.ValueInternal.Companion.decodeWith(msg: co } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.ValueInternal.computeSize(): Int { @@ -367,6 +368,8 @@ public fun com.google.protobuf.kotlin.ListValueInternal.Companion.decodeWith(msg } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.ListValueInternal.computeSize(): Int { @@ -425,6 +428,8 @@ public fun com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal.Compani } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt index c3b2f51ea..02dae866f 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt @@ -30,7 +30,6 @@ public class TimestampInternal: com.google.protobuf.kotlin.Timestamp, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.TimestampInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -81,6 +80,8 @@ public fun com.google.protobuf.kotlin.TimestampInternal.Companion.decodeWith(msg } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.TimestampInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt index 1b883b0f4..90c121bae 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt @@ -39,7 +39,6 @@ public class TypeInternal: com.google.protobuf.kotlin.Type, kotlinx.rpc.protobuf kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.TypeInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -82,7 +81,6 @@ public class FieldInternal: com.google.protobuf.kotlin.Field, kotlinx.rpc.protob kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.FieldInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -125,7 +123,6 @@ public class EnumInternal: com.google.protobuf.kotlin.Enum, kotlinx.rpc.protobuf kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.EnumInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -161,7 +158,6 @@ public class EnumValueInternal: com.google.protobuf.kotlin.EnumValue, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.EnumValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -200,7 +196,6 @@ public class OptionInternal: com.google.protobuf.kotlin.Option, kotlinx.rpc.prot kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.OptionInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -341,6 +336,8 @@ public fun com.google.protobuf.kotlin.TypeInternal.Companion.decodeWith(msg: com } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.TypeInternal.computeSize(): Int { @@ -487,6 +484,8 @@ public fun com.google.protobuf.kotlin.FieldInternal.Companion.decodeWith(msg: co } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.FieldInternal.computeSize(): Int { @@ -629,6 +628,8 @@ public fun com.google.protobuf.kotlin.EnumInternal.Companion.decodeWith(msg: com } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.EnumInternal.computeSize(): Int { @@ -715,6 +716,8 @@ public fun com.google.protobuf.kotlin.EnumValueInternal.Companion.decodeWith(msg } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.EnumValueInternal.computeSize(): Int { @@ -781,6 +784,8 @@ public fun com.google.protobuf.kotlin.OptionInternal.Companion.decodeWith(msg: c } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.OptionInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt index 19f862504..9a885691c 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt @@ -29,7 +29,6 @@ public class DoubleValueInternal: com.google.protobuf.kotlin.DoubleValue, kotlin kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.DoubleValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -63,7 +62,6 @@ public class FloatValueInternal: com.google.protobuf.kotlin.FloatValue, kotlinx. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.FloatValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -97,7 +95,6 @@ public class Int64ValueInternal: com.google.protobuf.kotlin.Int64Value, kotlinx. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.Int64ValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -131,7 +128,6 @@ public class UInt64ValueInternal: com.google.protobuf.kotlin.UInt64Value, kotlin kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.UInt64ValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -165,7 +161,6 @@ public class Int32ValueInternal: com.google.protobuf.kotlin.Int32Value, kotlinx. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.Int32ValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -199,7 +194,6 @@ public class UInt32ValueInternal: com.google.protobuf.kotlin.UInt32Value, kotlin kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.UInt32ValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -233,7 +227,6 @@ public class BoolValueInternal: com.google.protobuf.kotlin.BoolValue, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.BoolValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -267,7 +260,6 @@ public class StringValueInternal: com.google.protobuf.kotlin.StringValue, kotlin kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.StringValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -301,7 +293,6 @@ public class BytesValueInternal: com.google.protobuf.kotlin.BytesValue, kotlinx. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.BytesValueInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -392,6 +383,8 @@ public fun com.google.protobuf.kotlin.DoubleValueInternal.Companion.decodeWith(m } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.DoubleValueInternal.computeSize(): Int { @@ -435,6 +428,8 @@ public fun com.google.protobuf.kotlin.FloatValueInternal.Companion.decodeWith(ms } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.FloatValueInternal.computeSize(): Int { @@ -478,6 +473,8 @@ public fun com.google.protobuf.kotlin.Int64ValueInternal.Companion.decodeWith(ms } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.Int64ValueInternal.computeSize(): Int { @@ -521,6 +518,8 @@ public fun com.google.protobuf.kotlin.UInt64ValueInternal.Companion.decodeWith(m } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.UInt64ValueInternal.computeSize(): Int { @@ -564,6 +563,8 @@ public fun com.google.protobuf.kotlin.Int32ValueInternal.Companion.decodeWith(ms } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.Int32ValueInternal.computeSize(): Int { @@ -607,6 +608,8 @@ public fun com.google.protobuf.kotlin.UInt32ValueInternal.Companion.decodeWith(m } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.UInt32ValueInternal.computeSize(): Int { @@ -650,6 +653,8 @@ public fun com.google.protobuf.kotlin.BoolValueInternal.Companion.decodeWith(msg } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.BoolValueInternal.computeSize(): Int { @@ -693,6 +698,8 @@ public fun com.google.protobuf.kotlin.StringValueInternal.Companion.decodeWith(m } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.StringValueInternal.computeSize(): Int { @@ -736,6 +743,8 @@ public fun com.google.protobuf.kotlin.BytesValueInternal.Companion.decodeWith(ms } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.BytesValueInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireDecoder.kt b/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireDecoder.kt index acfffcf4b..79a3324d9 100644 --- a/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireDecoder.kt +++ b/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireDecoder.kt @@ -84,6 +84,10 @@ public interface WireDecoder : AutoCloseable { if (len < 0) throw ProtobufDecodingException.negativeSize() val limit = pushLimit(len) decoder(msg, this) + if (bytesUntilLimit() != 0) { + throw ProtobufDecodingException.truncatedMessage() + } + popLimit(limit) } diff --git a/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireSize.kt b/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireSize.kt index d20491cf1..c9fe8fee2 100644 --- a/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireSize.kt +++ b/protobuf/protobuf-core/src/commonMain/kotlin/kotlinx/rpc/protobuf/internal/WireSize.kt @@ -35,22 +35,22 @@ public expect fun WireSize.sInt32(value: Int): Int public expect fun WireSize.sInt64(value: Long): Int @InternalRpcApi -public fun WireSize.float(value: Float): Int = 32 +public fun WireSize.float(value: Float): Int = 4 @InternalRpcApi -public fun WireSize.double(value: Double): Int = 64 +public fun WireSize.double(value: Double): Int = 8 @InternalRpcApi -public fun WireSize.fixed32(value: UInt): Int = 32 +public fun WireSize.fixed32(value: UInt): Int = 4 @InternalRpcApi -public fun WireSize.fixed64(value: ULong): Int = 64 +public fun WireSize.fixed64(value: ULong): Int = 8 @InternalRpcApi -public fun WireSize.sFixed32(value: Int): Int = 32 +public fun WireSize.sFixed32(value: Int): Int = 4 @InternalRpcApi -public fun WireSize.sFixed64(value: Long): Int = 64 +public fun WireSize.sFixed64(value: Long): Int = 8 @InternalRpcApi public fun WireSize.bool(value: Boolean): Int = int32(if (value) 1 else 0) @@ -86,22 +86,22 @@ public fun WireSize.packedSInt64(value: List): Int = value.sumOf { sInt64( public fun WireSize.packedEnum(value: List): Int = value.sumOf { enum(it) } @InternalRpcApi -public fun WireSize.packedFloat(value: List): Int = value.size * 32 +public fun WireSize.packedFloat(value: List): Int = value.size * 4 @InternalRpcApi -public fun WireSize.packedDouble(value: List): Int = value.size * 64 +public fun WireSize.packedDouble(value: List): Int = value.size * 8 @InternalRpcApi -public fun WireSize.packedFixed32(value: List): Int = value.size * 32 +public fun WireSize.packedFixed32(value: List): Int = value.size * 4 @InternalRpcApi -public fun WireSize.packedFixed64(value: List): Int = value.size * 64 +public fun WireSize.packedFixed64(value: List): Int = value.size * 8 @InternalRpcApi -public fun WireSize.packedSFixed32(value: List): Int = value.size * 32 +public fun WireSize.packedSFixed32(value: List): Int = value.size * 4 @InternalRpcApi -public fun WireSize.packedSFixed64(value: List): Int = value.size * 64 +public fun WireSize.packedSFixed64(value: List): Int = value.size * 8 @InternalRpcApi public fun WireSize.packedBool(value: List): Int = packedSInt32(value.map { if (it) 1 else 0 }) diff --git a/protobuf/protobuf-core/src/jvmMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.jvm.kt b/protobuf/protobuf-core/src/jvmMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.jvm.kt index a0461a899..6054d5668 100644 --- a/protobuf/protobuf-core/src/jvmMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.jvm.kt +++ b/protobuf/protobuf-core/src/jvmMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.jvm.kt @@ -178,7 +178,7 @@ private class WireEncoderJvm(sink: Sink) : WireEncoder { encode: T.(WireEncoder) -> Unit, ) { codedOutputStream.writeTag(fieldNr, WireType.LENGTH_DELIMITED.ordinal) - codedOutputStream.writeInt32NoTag(value._size) + codedOutputStream.writeUInt32NoTag(value._size) value.encode(this) } @@ -190,7 +190,7 @@ private class WireEncoderJvm(sink: Sink) : WireEncoder { ) { codedOutputStream.writeTag(fieldNr, WireType.LENGTH_DELIMITED.ordinal) // write the field size of the packed field - codedOutputStream.writeInt32NoTag(fieldSize) + codedOutputStream.writeUInt32NoTag(fieldSize) for (v in value) { writer(codedOutputStream, v) } @@ -207,4 +207,4 @@ public actual inline fun checkForPlatformEncodeException(block: () -> Unit) { } catch (e: IOException) { throw ProtobufEncodingException("Failed to encode protobuf message.", e) } -} \ No newline at end of file +} diff --git a/protobuf/protobuf-core/src/nativeMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.native.kt b/protobuf/protobuf-core/src/nativeMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.native.kt index e0321b2db..b8171c74d 100644 --- a/protobuf/protobuf-core/src/nativeMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.native.kt +++ b/protobuf/protobuf-core/src/nativeMain/kotlin/kotlinx/rpc/protobuf/internal/WireEncoder.native.kt @@ -174,7 +174,7 @@ internal class WireEncoderNative(private val sink: Sink) : WireEncoder { encode: T.(WireEncoder) -> Unit, ) { pw_encoder_write_tag(raw, fieldNr, WireType.LENGTH_DELIMITED.ordinal) - pw_encoder_write_int32_no_tag(raw, value._size) + pw_encoder_write_uint32_no_tag(raw, value._size.toUInt()) value.encode(this) } } @@ -193,7 +193,7 @@ private inline fun WireEncoderNative.writePackedInternal( ) = checked { pw_encoder_write_tag(raw, fieldNr, WireType.LENGTH_DELIMITED.ordinal) // write the field size of the packed field - pw_encoder_write_int32_no_tag(raw, fieldSize) + pw_encoder_write_uint32_no_tag(raw, fieldSize.toUInt()) for (v in value) { if (!writer(raw, v)) { return@checked false @@ -213,4 +213,4 @@ private inline fun checked(crossinline block: () -> Boolean) { public actual inline fun checkForPlatformEncodeException(block: () -> Unit) { block() // nothing to check for on native -} \ No newline at end of file +} diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt index 296bf640b..6b3c89229 100644 --- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt +++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt @@ -35,6 +35,7 @@ sealed interface FieldType { data class Enum(val dec: EnumDeclaration) : FieldType { override val defaultValue = dec.defaultEntry().name.fullName() override val wireType: WireType = WireType.VARINT + override val isPackable: Boolean = true } data class Message(val dec: Lazy) : FieldType { diff --git a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt index 4755dcdd1..2f5695f22 100644 --- a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt +++ b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt @@ -20,7 +20,6 @@ import kotlinx.rpc.protoc.gen.core.model.Model import kotlinx.rpc.protoc.gen.core.model.OneOfDeclaration import kotlinx.rpc.protoc.gen.core.model.WireType import org.slf4j.Logger -import kotlin.collections.map class ModelToProtobufKotlinCommonGenerator( model: Model, @@ -227,7 +226,6 @@ class ModelToProtobufKotlinCommonGenerator( scope("${PB_PKG}.checkForPlatformDecodeException", nlAfterClosed = false) { code("${declaration.internalClassFullName()}.decodeWith(msg, it)") } - code("msg.checkRequiredFields()") code("return msg") } } @@ -271,6 +269,8 @@ class ModelToProtobufKotlinCommonGenerator( } } + code("msg.checkRequiredFields()") + // TODO: Make lists and maps immutable (KRPC-190) } @@ -286,12 +286,17 @@ class ModelToProtobufKotlinCommonGenerator( generateDecodeFieldValue(fieldType, lvalue, wrapperCtor = wrapperCtor) } - is FieldType.List -> if (field.dec.isPacked) { - whenCase("tag.fieldNr == ${field.number} && tag.wireType == $PB_PKG.WireType.LENGTH_DELIMITED") { - beforeValueDecoding() - generateDecodeFieldValue(fieldType, lvalue, isPacked = true, wrapperCtor = wrapperCtor) + is FieldType.List -> { + // Protocol buffer parsers must be able + // to parse repeated fields that were compiled as packed as if they were not packed, + // and vice versa. + if (fieldType.value.isPackable) { + whenCase("tag.fieldNr == ${field.number} && tag.wireType == $PB_PKG.WireType.LENGTH_DELIMITED") { + beforeValueDecoding() + generateDecodeFieldValue(fieldType, lvalue, isPacked = true, wrapperCtor = wrapperCtor) + } } - } else { + whenCase("tag.fieldNr == ${field.number} && tag.wireType == $PB_PKG.WireType.${fieldType.value.wireType.name}") { beforeValueDecoding() generateDecodeFieldValue(fieldType, lvalue, isPacked = false, wrapperCtor = wrapperCtor) @@ -370,7 +375,11 @@ class ModelToProtobufKotlinCommonGenerator( "" } - code("$lvalue = decoder.readPacked${fieldType.value.decodeEncodeFuncName()}()$conversion") + // Note that although there’s usually no reason + // to encode more than one key-value pair for a packed repeated field, + // parsers must be prepared to accept multiple key-value pairs. + // In this case, the payloads should be concatenated. + code("$lvalue += decoder.readPacked${fieldType.value.decodeEncodeFuncName()}()$conversion") } else { when (val elemType = fieldType.value) { is FieldType.Message -> { @@ -455,7 +464,9 @@ class ModelToProtobufKotlinCommonGenerator( valueVar: String, ) { generateEncodeFieldValue( - valueVar, field.type, number = field.number, + valueVar = valueVar, + type = field.type, + number = field.number, isPacked = field.dec.isPacked, packedWithFixedSize = field.packedFixedSize ) @@ -521,7 +532,9 @@ class ModelToProtobufKotlinCommonGenerator( generateEncodeFieldValue( valueVar = "entry", type = FieldType.Message(lazy { type.entry.dec }), - number = number, isPacked = false, packedWithFixedSize = false + number = number, + isPacked = false, + packedWithFixedSize = false, ) } } diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt index 944dec0b7..4ea7c5c33 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt @@ -31,7 +31,6 @@ class TestStatusInternal: com.google.protobuf.conformance.TestStatus, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.TestStatusInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -65,7 +64,6 @@ class FailureSetInternal: com.google.protobuf.conformance.FailureSet, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.FailureSetInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -108,7 +106,6 @@ class ConformanceRequestInternal: com.google.protobuf.conformance.ConformanceReq kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.ConformanceRequestInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -142,7 +139,6 @@ class ConformanceResponseInternal: com.google.protobuf.conformance.ConformanceRe kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.ConformanceResponseInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -176,7 +172,6 @@ class JspbEncodingConfigInternal: com.google.protobuf.conformance.JspbEncodingCo kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.JspbEncodingConfigInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -259,6 +254,8 @@ fun com.google.protobuf.conformance.TestStatusInternal.Companion.decodeWith(msg: } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.conformance.TestStatusInternal.computeSize(): Int { @@ -317,6 +314,8 @@ fun com.google.protobuf.conformance.FailureSetInternal.Companion.decodeWith(msg: } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.conformance.FailureSetInternal.computeSize(): Int { @@ -435,6 +434,8 @@ fun com.google.protobuf.conformance.ConformanceRequestInternal.Companion.decodeW } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.conformance.ConformanceRequestInternal.computeSize(): Int { @@ -582,6 +583,8 @@ fun com.google.protobuf.conformance.ConformanceResponseInternal.Companion.decode } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.conformance.ConformanceResponseInternal.computeSize(): Int { @@ -661,6 +664,8 @@ fun com.google.protobuf.conformance.JspbEncodingConfigInternal.Companion.decodeW } } } + + msg.checkRequiredFields() } private fun com.google.protobuf.conformance.JspbEncodingConfigInternal.computeSize(): Int { diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt index f6c06b031..5cc526050 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt @@ -203,7 +203,6 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.editions.pro kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.NestedMessageInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -448,7 +447,6 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.editions.pro kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -482,7 +480,6 @@ class ForeignMessageInternal: com.google.protobuf_test_messages.editions.proto3. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.ForeignMessageInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -514,7 +511,6 @@ class NullHypothesisProto3Internal: com.google.protobuf_test_messages.editions.p kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.NullHypothesisProto3Internal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -546,7 +542,6 @@ class EnumOnlyProto3Internal: com.google.protobuf_test_messages.editions.proto3. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.EnumOnlyProto3Internal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -1695,55 +1690,120 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } tag.fieldNr == 31 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedInt32 = decoder.readPackedInt32() + msg.repeatedInt32 += decoder.readPackedInt32() + } + + tag.fieldNr == 31 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt32() + (msg.repeatedInt32 as MutableList).add(elem) } tag.fieldNr == 32 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedInt64 = decoder.readPackedInt64() + msg.repeatedInt64 += decoder.readPackedInt64() + } + + tag.fieldNr == 32 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt64() + (msg.repeatedInt64 as MutableList).add(elem) } tag.fieldNr == 33 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedUint32 = decoder.readPackedUInt32() + msg.repeatedUint32 += decoder.readPackedUInt32() + } + + tag.fieldNr == 33 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt32() + (msg.repeatedUint32 as MutableList).add(elem) } tag.fieldNr == 34 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedUint64 = decoder.readPackedUInt64() + msg.repeatedUint64 += decoder.readPackedUInt64() + } + + tag.fieldNr == 34 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt64() + (msg.repeatedUint64 as MutableList).add(elem) } tag.fieldNr == 35 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSint32 = decoder.readPackedSInt32() + msg.repeatedSint32 += decoder.readPackedSInt32() + } + + tag.fieldNr == 35 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt32() + (msg.repeatedSint32 as MutableList).add(elem) } tag.fieldNr == 36 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSint64 = decoder.readPackedSInt64() + msg.repeatedSint64 += decoder.readPackedSInt64() + } + + tag.fieldNr == 36 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt64() + (msg.repeatedSint64 as MutableList).add(elem) } tag.fieldNr == 37 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFixed32 = decoder.readPackedFixed32() + msg.repeatedFixed32 += decoder.readPackedFixed32() + } + + tag.fieldNr == 37 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFixed32() + (msg.repeatedFixed32 as MutableList).add(elem) } tag.fieldNr == 38 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFixed64 = decoder.readPackedFixed64() + msg.repeatedFixed64 += decoder.readPackedFixed64() + } + + tag.fieldNr == 38 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readFixed64() + (msg.repeatedFixed64 as MutableList).add(elem) } tag.fieldNr == 39 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSfixed32 = decoder.readPackedSFixed32() + msg.repeatedSfixed32 += decoder.readPackedSFixed32() + } + + tag.fieldNr == 39 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readSFixed32() + (msg.repeatedSfixed32 as MutableList).add(elem) } tag.fieldNr == 40 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSfixed64 = decoder.readPackedSFixed64() + msg.repeatedSfixed64 += decoder.readPackedSFixed64() + } + + tag.fieldNr == 40 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readSFixed64() + (msg.repeatedSfixed64 as MutableList).add(elem) } tag.fieldNr == 41 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFloat = decoder.readPackedFloat() + msg.repeatedFloat += decoder.readPackedFloat() + } + + tag.fieldNr == 41 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFloat() + (msg.repeatedFloat as MutableList).add(elem) } tag.fieldNr == 42 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedDouble = decoder.readPackedDouble() + msg.repeatedDouble += decoder.readPackedDouble() + } + + tag.fieldNr == 42 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readDouble() + (msg.repeatedDouble as MutableList).add(elem) } tag.fieldNr == 43 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedBool = decoder.readPackedBool() + msg.repeatedBool += decoder.readPackedBool() + } + + tag.fieldNr == 43 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readBool() + (msg.repeatedBool as MutableList).add(elem) } tag.fieldNr == 44 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { @@ -1769,11 +1829,21 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } tag.fieldNr == 51 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedNestedEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + msg.repeatedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + + tag.fieldNr == 51 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) + (msg.repeatedNestedEnum as MutableList).add(elem) } tag.fieldNr == 52 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedForeignEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.ForeignEnum.fromNumber(it) } + msg.repeatedForeignEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.ForeignEnum.fromNumber(it) } + } + + tag.fieldNr == 52 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.editions.proto3.ForeignEnum.fromNumber(decoder.readEnum()) + (msg.repeatedForeignEnum as MutableList).add(elem) } tag.fieldNr == 54 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { @@ -1787,59 +1857,133 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } tag.fieldNr == 75 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedInt32 = decoder.readPackedInt32() + msg.packedInt32 += decoder.readPackedInt32() + } + + tag.fieldNr == 75 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt32() + (msg.packedInt32 as MutableList).add(elem) } tag.fieldNr == 76 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedInt64 = decoder.readPackedInt64() + msg.packedInt64 += decoder.readPackedInt64() + } + + tag.fieldNr == 76 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt64() + (msg.packedInt64 as MutableList).add(elem) } tag.fieldNr == 77 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedUint32 = decoder.readPackedUInt32() + msg.packedUint32 += decoder.readPackedUInt32() + } + + tag.fieldNr == 77 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt32() + (msg.packedUint32 as MutableList).add(elem) } tag.fieldNr == 78 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedUint64 = decoder.readPackedUInt64() + msg.packedUint64 += decoder.readPackedUInt64() + } + + tag.fieldNr == 78 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt64() + (msg.packedUint64 as MutableList).add(elem) } tag.fieldNr == 79 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSint32 = decoder.readPackedSInt32() + msg.packedSint32 += decoder.readPackedSInt32() + } + + tag.fieldNr == 79 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt32() + (msg.packedSint32 as MutableList).add(elem) } tag.fieldNr == 80 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSint64 = decoder.readPackedSInt64() + msg.packedSint64 += decoder.readPackedSInt64() + } + + tag.fieldNr == 80 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt64() + (msg.packedSint64 as MutableList).add(elem) } tag.fieldNr == 81 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFixed32 = decoder.readPackedFixed32() + msg.packedFixed32 += decoder.readPackedFixed32() + } + + tag.fieldNr == 81 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFixed32() + (msg.packedFixed32 as MutableList).add(elem) } tag.fieldNr == 82 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFixed64 = decoder.readPackedFixed64() + msg.packedFixed64 += decoder.readPackedFixed64() + } + + tag.fieldNr == 82 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readFixed64() + (msg.packedFixed64 as MutableList).add(elem) } tag.fieldNr == 83 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSfixed32 = decoder.readPackedSFixed32() + msg.packedSfixed32 += decoder.readPackedSFixed32() + } + + tag.fieldNr == 83 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readSFixed32() + (msg.packedSfixed32 as MutableList).add(elem) } tag.fieldNr == 84 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSfixed64 = decoder.readPackedSFixed64() + msg.packedSfixed64 += decoder.readPackedSFixed64() + } + + tag.fieldNr == 84 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readSFixed64() + (msg.packedSfixed64 as MutableList).add(elem) } tag.fieldNr == 85 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFloat = decoder.readPackedFloat() + msg.packedFloat += decoder.readPackedFloat() + } + + tag.fieldNr == 85 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFloat() + (msg.packedFloat as MutableList).add(elem) } tag.fieldNr == 86 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedDouble = decoder.readPackedDouble() + msg.packedDouble += decoder.readPackedDouble() + } + + tag.fieldNr == 86 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readDouble() + (msg.packedDouble as MutableList).add(elem) } tag.fieldNr == 87 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedBool = decoder.readPackedBool() + msg.packedBool += decoder.readPackedBool() + } + + tag.fieldNr == 87 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readBool() + (msg.packedBool as MutableList).add(elem) } tag.fieldNr == 88 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedNestedEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + msg.packedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + + tag.fieldNr == 88 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) + (msg.packedNestedEnum as MutableList).add(elem) + } + + tag.fieldNr == 89 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedInt32 += decoder.readPackedInt32() } tag.fieldNr == 89 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { @@ -1847,66 +1991,118 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal (msg.unpackedInt32 as MutableList).add(elem) } + tag.fieldNr == 90 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedInt64 += decoder.readPackedInt64() + } + tag.fieldNr == 90 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readInt64() (msg.unpackedInt64 as MutableList).add(elem) } + tag.fieldNr == 91 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedUint32 += decoder.readPackedUInt32() + } + tag.fieldNr == 91 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readUInt32() (msg.unpackedUint32 as MutableList).add(elem) } + tag.fieldNr == 92 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedUint64 += decoder.readPackedUInt64() + } + tag.fieldNr == 92 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readUInt64() (msg.unpackedUint64 as MutableList).add(elem) } + tag.fieldNr == 93 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSint32 += decoder.readPackedSInt32() + } + tag.fieldNr == 93 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readSInt32() (msg.unpackedSint32 as MutableList).add(elem) } + tag.fieldNr == 94 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSint64 += decoder.readPackedSInt64() + } + tag.fieldNr == 94 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readSInt64() (msg.unpackedSint64 as MutableList).add(elem) } + tag.fieldNr == 95 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFixed32 += decoder.readPackedFixed32() + } + tag.fieldNr == 95 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readFixed32() (msg.unpackedFixed32 as MutableList).add(elem) } + tag.fieldNr == 96 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFixed64 += decoder.readPackedFixed64() + } + tag.fieldNr == 96 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readFixed64() (msg.unpackedFixed64 as MutableList).add(elem) } + tag.fieldNr == 97 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSfixed32 += decoder.readPackedSFixed32() + } + tag.fieldNr == 97 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readSFixed32() (msg.unpackedSfixed32 as MutableList).add(elem) } + tag.fieldNr == 98 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSfixed64 += decoder.readPackedSFixed64() + } + tag.fieldNr == 98 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readSFixed64() (msg.unpackedSfixed64 as MutableList).add(elem) } + tag.fieldNr == 99 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFloat += decoder.readPackedFloat() + } + tag.fieldNr == 99 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readFloat() (msg.unpackedFloat as MutableList).add(elem) } + tag.fieldNr == 100 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedDouble += decoder.readPackedDouble() + } + tag.fieldNr == 100 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readDouble() (msg.unpackedDouble as MutableList).add(elem) } + tag.fieldNr == 101 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedBool += decoder.readPackedBool() + } + tag.fieldNr == 101 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readBool() (msg.unpackedBool as MutableList).add(elem) } + tag.fieldNr == 102 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + tag.fieldNr == 102 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) (msg.unpackedNestedEnum as MutableList).add(elem) @@ -2387,6 +2583,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.computeSize(): Int { @@ -3148,6 +3346,8 @@ fun com.google.protobuf_test_messages.editions.proto3.ForeignMessageInternal.Com } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.ForeignMessageInternal.computeSize(): Int { @@ -3185,6 +3385,8 @@ fun com.google.protobuf_test_messages.editions.proto3.NullHypothesisProto3Intern } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.NullHypothesisProto3Internal.computeSize(): Int { @@ -3218,6 +3420,8 @@ fun com.google.protobuf_test_messages.editions.proto3.EnumOnlyProto3Internal.Com } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.EnumOnlyProto3Internal.computeSize(): Int { @@ -3272,6 +3476,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.NestedMessageInternal.computeSize(): Int { @@ -3327,6 +3533,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapInt32Int32EntryInternal.computeSize(): Int { @@ -3382,6 +3590,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapInt64Int64EntryInternal.computeSize(): Int { @@ -3437,6 +3647,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapUint32Uint32EntryInternal.computeSize(): Int { @@ -3492,6 +3704,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapUint64Uint64EntryInternal.computeSize(): Int { @@ -3547,6 +3761,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapSint32Sint32EntryInternal.computeSize(): Int { @@ -3602,6 +3818,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapSint64Sint64EntryInternal.computeSize(): Int { @@ -3657,6 +3875,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapFixed32Fixed32EntryInternal.computeSize(): Int { @@ -3712,6 +3932,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapFixed64Fixed64EntryInternal.computeSize(): Int { @@ -3767,6 +3989,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapSfixed32Sfixed32EntryInternal.computeSize(): Int { @@ -3822,6 +4046,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapSfixed64Sfixed64EntryInternal.computeSize(): Int { @@ -3877,6 +4103,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapInt32FloatEntryInternal.computeSize(): Int { @@ -3932,6 +4160,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapInt32DoubleEntryInternal.computeSize(): Int { @@ -3987,6 +4217,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapBoolBoolEntryInternal.computeSize(): Int { @@ -4042,6 +4274,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringStringEntryInternal.computeSize(): Int { @@ -4097,6 +4331,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringBytesEntryInternal.computeSize(): Int { @@ -4159,6 +4395,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringNestedMessageEntryInternal.computeSize(): Int { @@ -4221,6 +4459,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringForeignMessageEntryInternal.computeSize(): Int { @@ -4276,6 +4516,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringNestedEnumEntryInternal.computeSize(): Int { @@ -4331,6 +4573,8 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringForeignEnumEntryInternal.computeSize(): Int { diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt index acaf18379..bd9c57aae 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt @@ -203,7 +203,6 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.proto3.TestA kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.NestedMessageInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -448,7 +447,6 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.proto3.TestA kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -482,7 +480,6 @@ class ForeignMessageInternal: com.google.protobuf_test_messages.proto3.ForeignMe kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.ForeignMessageInternal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -514,7 +511,6 @@ class NullHypothesisProto3Internal: com.google.protobuf_test_messages.proto3.Nul kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.NullHypothesisProto3Internal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -546,7 +542,6 @@ class EnumOnlyProto3Internal: com.google.protobuf_test_messages.proto3.EnumOnlyP kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.EnumOnlyProto3Internal.decodeWith(msg, it) } - msg.checkRequiredFields() return msg } } @@ -1695,55 +1690,120 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio } tag.fieldNr == 31 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedInt32 = decoder.readPackedInt32() + msg.repeatedInt32 += decoder.readPackedInt32() + } + + tag.fieldNr == 31 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt32() + (msg.repeatedInt32 as MutableList).add(elem) } tag.fieldNr == 32 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedInt64 = decoder.readPackedInt64() + msg.repeatedInt64 += decoder.readPackedInt64() + } + + tag.fieldNr == 32 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt64() + (msg.repeatedInt64 as MutableList).add(elem) } tag.fieldNr == 33 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedUint32 = decoder.readPackedUInt32() + msg.repeatedUint32 += decoder.readPackedUInt32() + } + + tag.fieldNr == 33 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt32() + (msg.repeatedUint32 as MutableList).add(elem) } tag.fieldNr == 34 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedUint64 = decoder.readPackedUInt64() + msg.repeatedUint64 += decoder.readPackedUInt64() + } + + tag.fieldNr == 34 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt64() + (msg.repeatedUint64 as MutableList).add(elem) } tag.fieldNr == 35 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSint32 = decoder.readPackedSInt32() + msg.repeatedSint32 += decoder.readPackedSInt32() + } + + tag.fieldNr == 35 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt32() + (msg.repeatedSint32 as MutableList).add(elem) } tag.fieldNr == 36 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSint64 = decoder.readPackedSInt64() + msg.repeatedSint64 += decoder.readPackedSInt64() + } + + tag.fieldNr == 36 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt64() + (msg.repeatedSint64 as MutableList).add(elem) } tag.fieldNr == 37 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFixed32 = decoder.readPackedFixed32() + msg.repeatedFixed32 += decoder.readPackedFixed32() + } + + tag.fieldNr == 37 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFixed32() + (msg.repeatedFixed32 as MutableList).add(elem) } tag.fieldNr == 38 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFixed64 = decoder.readPackedFixed64() + msg.repeatedFixed64 += decoder.readPackedFixed64() + } + + tag.fieldNr == 38 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readFixed64() + (msg.repeatedFixed64 as MutableList).add(elem) } tag.fieldNr == 39 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSfixed32 = decoder.readPackedSFixed32() + msg.repeatedSfixed32 += decoder.readPackedSFixed32() + } + + tag.fieldNr == 39 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readSFixed32() + (msg.repeatedSfixed32 as MutableList).add(elem) } tag.fieldNr == 40 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedSfixed64 = decoder.readPackedSFixed64() + msg.repeatedSfixed64 += decoder.readPackedSFixed64() + } + + tag.fieldNr == 40 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readSFixed64() + (msg.repeatedSfixed64 as MutableList).add(elem) } tag.fieldNr == 41 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedFloat = decoder.readPackedFloat() + msg.repeatedFloat += decoder.readPackedFloat() + } + + tag.fieldNr == 41 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFloat() + (msg.repeatedFloat as MutableList).add(elem) } tag.fieldNr == 42 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedDouble = decoder.readPackedDouble() + msg.repeatedDouble += decoder.readPackedDouble() + } + + tag.fieldNr == 42 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readDouble() + (msg.repeatedDouble as MutableList).add(elem) } tag.fieldNr == 43 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedBool = decoder.readPackedBool() + msg.repeatedBool += decoder.readPackedBool() + } + + tag.fieldNr == 43 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readBool() + (msg.repeatedBool as MutableList).add(elem) } tag.fieldNr == 44 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { @@ -1769,11 +1829,21 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio } tag.fieldNr == 51 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedNestedEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + msg.repeatedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + + tag.fieldNr == 51 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) + (msg.repeatedNestedEnum as MutableList).add(elem) } tag.fieldNr == 52 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.repeatedForeignEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.ForeignEnum.fromNumber(it) } + msg.repeatedForeignEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.ForeignEnum.fromNumber(it) } + } + + tag.fieldNr == 52 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.proto3.ForeignEnum.fromNumber(decoder.readEnum()) + (msg.repeatedForeignEnum as MutableList).add(elem) } tag.fieldNr == 54 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { @@ -1787,59 +1857,133 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio } tag.fieldNr == 75 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedInt32 = decoder.readPackedInt32() + msg.packedInt32 += decoder.readPackedInt32() + } + + tag.fieldNr == 75 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt32() + (msg.packedInt32 as MutableList).add(elem) } tag.fieldNr == 76 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedInt64 = decoder.readPackedInt64() + msg.packedInt64 += decoder.readPackedInt64() + } + + tag.fieldNr == 76 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readInt64() + (msg.packedInt64 as MutableList).add(elem) } tag.fieldNr == 77 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedUint32 = decoder.readPackedUInt32() + msg.packedUint32 += decoder.readPackedUInt32() + } + + tag.fieldNr == 77 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt32() + (msg.packedUint32 as MutableList).add(elem) } tag.fieldNr == 78 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedUint64 = decoder.readPackedUInt64() + msg.packedUint64 += decoder.readPackedUInt64() + } + + tag.fieldNr == 78 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readUInt64() + (msg.packedUint64 as MutableList).add(elem) } tag.fieldNr == 79 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSint32 = decoder.readPackedSInt32() + msg.packedSint32 += decoder.readPackedSInt32() + } + + tag.fieldNr == 79 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt32() + (msg.packedSint32 as MutableList).add(elem) } tag.fieldNr == 80 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSint64 = decoder.readPackedSInt64() + msg.packedSint64 += decoder.readPackedSInt64() + } + + tag.fieldNr == 80 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readSInt64() + (msg.packedSint64 as MutableList).add(elem) } tag.fieldNr == 81 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFixed32 = decoder.readPackedFixed32() + msg.packedFixed32 += decoder.readPackedFixed32() + } + + tag.fieldNr == 81 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFixed32() + (msg.packedFixed32 as MutableList).add(elem) } tag.fieldNr == 82 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFixed64 = decoder.readPackedFixed64() + msg.packedFixed64 += decoder.readPackedFixed64() + } + + tag.fieldNr == 82 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readFixed64() + (msg.packedFixed64 as MutableList).add(elem) } tag.fieldNr == 83 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSfixed32 = decoder.readPackedSFixed32() + msg.packedSfixed32 += decoder.readPackedSFixed32() + } + + tag.fieldNr == 83 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readSFixed32() + (msg.packedSfixed32 as MutableList).add(elem) } tag.fieldNr == 84 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedSfixed64 = decoder.readPackedSFixed64() + msg.packedSfixed64 += decoder.readPackedSFixed64() + } + + tag.fieldNr == 84 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readSFixed64() + (msg.packedSfixed64 as MutableList).add(elem) } tag.fieldNr == 85 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedFloat = decoder.readPackedFloat() + msg.packedFloat += decoder.readPackedFloat() + } + + tag.fieldNr == 85 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { + val elem = decoder.readFloat() + (msg.packedFloat as MutableList).add(elem) } tag.fieldNr == 86 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedDouble = decoder.readPackedDouble() + msg.packedDouble += decoder.readPackedDouble() + } + + tag.fieldNr == 86 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { + val elem = decoder.readDouble() + (msg.packedDouble as MutableList).add(elem) } tag.fieldNr == 87 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedBool = decoder.readPackedBool() + msg.packedBool += decoder.readPackedBool() + } + + tag.fieldNr == 87 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = decoder.readBool() + (msg.packedBool as MutableList).add(elem) } tag.fieldNr == 88 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { - msg.packedNestedEnum = decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + msg.packedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + + tag.fieldNr == 88 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { + val elem = com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) + (msg.packedNestedEnum as MutableList).add(elem) + } + + tag.fieldNr == 89 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedInt32 += decoder.readPackedInt32() } tag.fieldNr == 89 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { @@ -1847,66 +1991,118 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio (msg.unpackedInt32 as MutableList).add(elem) } + tag.fieldNr == 90 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedInt64 += decoder.readPackedInt64() + } + tag.fieldNr == 90 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readInt64() (msg.unpackedInt64 as MutableList).add(elem) } + tag.fieldNr == 91 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedUint32 += decoder.readPackedUInt32() + } + tag.fieldNr == 91 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readUInt32() (msg.unpackedUint32 as MutableList).add(elem) } + tag.fieldNr == 92 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedUint64 += decoder.readPackedUInt64() + } + tag.fieldNr == 92 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readUInt64() (msg.unpackedUint64 as MutableList).add(elem) } + tag.fieldNr == 93 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSint32 += decoder.readPackedSInt32() + } + tag.fieldNr == 93 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readSInt32() (msg.unpackedSint32 as MutableList).add(elem) } + tag.fieldNr == 94 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSint64 += decoder.readPackedSInt64() + } + tag.fieldNr == 94 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readSInt64() (msg.unpackedSint64 as MutableList).add(elem) } + tag.fieldNr == 95 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFixed32 += decoder.readPackedFixed32() + } + tag.fieldNr == 95 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readFixed32() (msg.unpackedFixed32 as MutableList).add(elem) } + tag.fieldNr == 96 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFixed64 += decoder.readPackedFixed64() + } + tag.fieldNr == 96 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readFixed64() (msg.unpackedFixed64 as MutableList).add(elem) } + tag.fieldNr == 97 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSfixed32 += decoder.readPackedSFixed32() + } + tag.fieldNr == 97 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readSFixed32() (msg.unpackedSfixed32 as MutableList).add(elem) } + tag.fieldNr == 98 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedSfixed64 += decoder.readPackedSFixed64() + } + tag.fieldNr == 98 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readSFixed64() (msg.unpackedSfixed64 as MutableList).add(elem) } + tag.fieldNr == 99 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedFloat += decoder.readPackedFloat() + } + tag.fieldNr == 99 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED32 -> { val elem = decoder.readFloat() (msg.unpackedFloat as MutableList).add(elem) } + tag.fieldNr == 100 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedDouble += decoder.readPackedDouble() + } + tag.fieldNr == 100 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.FIXED64 -> { val elem = decoder.readDouble() (msg.unpackedDouble as MutableList).add(elem) } + tag.fieldNr == 101 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedBool += decoder.readPackedBool() + } + tag.fieldNr == 101 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = decoder.readBool() (msg.unpackedBool as MutableList).add(elem) } + tag.fieldNr == 102 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> { + msg.unpackedNestedEnum += decoder.readPackedEnum().map { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(it) } + } + tag.fieldNr == 102 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> { val elem = com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.fromNumber(decoder.readEnum()) (msg.unpackedNestedEnum as MutableList).add(elem) @@ -2387,6 +2583,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.computeSize(): Int { @@ -3148,6 +3346,8 @@ fun com.google.protobuf_test_messages.proto3.ForeignMessageInternal.Companion.de } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.ForeignMessageInternal.computeSize(): Int { @@ -3185,6 +3385,8 @@ fun com.google.protobuf_test_messages.proto3.NullHypothesisProto3Internal.Compan } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.NullHypothesisProto3Internal.computeSize(): Int { @@ -3218,6 +3420,8 @@ fun com.google.protobuf_test_messages.proto3.EnumOnlyProto3Internal.Companion.de } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.EnumOnlyProto3Internal.computeSize(): Int { @@ -3272,6 +3476,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.NestedMe } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.NestedMessageInternal.computeSize(): Int { @@ -3327,6 +3533,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32 } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32Int32EntryInternal.computeSize(): Int { @@ -3382,6 +3590,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt64 } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt64Int64EntryInternal.computeSize(): Int { @@ -3437,6 +3647,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapUint3 } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapUint32Uint32EntryInternal.computeSize(): Int { @@ -3492,6 +3704,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapUint6 } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapUint64Uint64EntryInternal.computeSize(): Int { @@ -3547,6 +3761,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSint3 } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSint32Sint32EntryInternal.computeSize(): Int { @@ -3602,6 +3818,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSint6 } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSint64Sint64EntryInternal.computeSize(): Int { @@ -3657,6 +3875,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapFixed } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapFixed32Fixed32EntryInternal.computeSize(): Int { @@ -3712,6 +3932,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapFixed } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapFixed64Fixed64EntryInternal.computeSize(): Int { @@ -3767,6 +3989,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSfixe } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSfixed32Sfixed32EntryInternal.computeSize(): Int { @@ -3822,6 +4046,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSfixe } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSfixed64Sfixed64EntryInternal.computeSize(): Int { @@ -3877,6 +4103,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32 } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32FloatEntryInternal.computeSize(): Int { @@ -3932,6 +4160,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32 } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32DoubleEntryInternal.computeSize(): Int { @@ -3987,6 +4217,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapBoolB } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapBoolBoolEntryInternal.computeSize(): Int { @@ -4042,6 +4274,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringStringEntryInternal.computeSize(): Int { @@ -4097,6 +4331,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringBytesEntryInternal.computeSize(): Int { @@ -4159,6 +4395,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringNestedMessageEntryInternal.computeSize(): Int { @@ -4221,6 +4459,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringForeignMessageEntryInternal.computeSize(): Int { @@ -4276,6 +4516,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringNestedEnumEntryInternal.computeSize(): Int { @@ -4331,6 +4573,8 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } + + msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringForeignEnumEntryInternal.computeSize(): Int { From 05ecf323f1e95b91343b69e429d8c1cd874d313e Mon Sep 17 00:00:00 2001 From: Alexander Sysoev Date: Tue, 19 Aug 2025 11:41:07 +0200 Subject: [PATCH 2/5] Fix default values --- .../kotlin/conventions-protoc-gen.gradle.kts | 24 ++-- .../protobuf/kotlin/_rpc_internal/Api.kt | 8 +- .../protobuf/kotlin/_rpc_internal/Type.kt | 16 +-- .../src/commonTest/proto/all_primitives.proto | 2 + .../src/commonTest/proto/default.proto | 32 +++++ .../rpc/protoc/gen/core/codeRequestToModel.kt | 2 +- .../rpc/protoc/gen/core/model/FieldType.kt | 20 +++- .../rpc/protoc/gen/core/model/model.kt | 6 +- .../ModelToProtobufKotlinCommonGenerator.kt | 111 +++++++++++++++--- .../conformance/_rpc_internal/Conformance.kt | 8 +- .../TestMessagesProto3Editions.kt | 28 ++--- .../_rpc_internal/TestMessagesProto3.kt | 28 ++--- .../rpc/protoc/gen/test/runner/runner.kt | 15 ++- 13 files changed, 222 insertions(+), 78 deletions(-) create mode 100644 protobuf/protobuf-core/src/commonTest/proto/default.proto diff --git a/gradle-conventions/src/main/kotlin/conventions-protoc-gen.gradle.kts b/gradle-conventions/src/main/kotlin/conventions-protoc-gen.gradle.kts index 8c228ee27..28d339026 100644 --- a/gradle-conventions/src/main/kotlin/conventions-protoc-gen.gradle.kts +++ b/gradle-conventions/src/main/kotlin/conventions-protoc-gen.gradle.kts @@ -18,17 +18,19 @@ dependencies { testImplementation(libs.kotlin.test) } -tasks.jar { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - archiveClassifier = "all" - - // Protoc plugins are all fat jars basically (the ones built on jvm) - // be really careful of what you put in the classpath here - from( - configurations.runtimeClasspath.map { prop -> - prop.map { if (it.isDirectory()) it else zipTree(it) } - } - ) +if (project.name != "common") { + tasks.jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + archiveClassifier = "all" + + // Protoc plugins are all fat jars basically (the ones built on jvm) + // be really careful of what you put in the classpath here + from( + configurations.runtimeClasspath.map { prop -> + prop.map { if (it.isDirectory()) it else zipTree(it) } + } + ) + } } kotlin { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt index 11bba50de..9dcd9cd07 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt @@ -191,7 +191,7 @@ public fun com.google.protobuf.kotlin.ApiInternal.encodeWith(encoder: kotlinx.rp } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { encoder.writeEnum(fieldNr = 7, value = syntax.number) } } @@ -275,7 +275,7 @@ private fun com.google.protobuf.kotlin.ApiInternal.computeSize(): Int { __result = mixins.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(7, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number)) } @@ -323,7 +323,7 @@ public fun com.google.protobuf.kotlin.MethodInternal.encodeWith(encoder: kotlinx } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { encoder.writeEnum(fieldNr = 7, value = syntax.number) } } @@ -399,7 +399,7 @@ private fun com.google.protobuf.kotlin.MethodInternal.computeSize(): Int { __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(7, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number)) } diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt index 90c121bae..efa9b8bf1 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt @@ -279,7 +279,7 @@ public fun com.google.protobuf.kotlin.TypeInternal.encodeWith(encoder: kotlinx.r encoder.writeMessage(fieldNr = 5, value = sourceContext.asInternal()) { encodeWith(it) } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { encoder.writeEnum(fieldNr = 6, value = syntax.number) } @@ -362,7 +362,7 @@ private fun com.google.protobuf.kotlin.TypeInternal.computeSize(): Int { __result += sourceContext.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(5, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number)) } @@ -388,11 +388,11 @@ public fun com.google.protobuf.kotlin.FieldInternal.checkRequiredFields() { @kotlinx.rpc.internal.utils.InternalRpcApi public fun com.google.protobuf.kotlin.FieldInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) { - if (com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN != kind) { + if (kind != com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN) { encoder.writeEnum(fieldNr = 1, value = kind.number) } - if (com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN != cardinality) { + if (cardinality != com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN) { encoder.writeEnum(fieldNr = 2, value = cardinality.number) } @@ -490,11 +490,11 @@ public fun com.google.protobuf.kotlin.FieldInternal.Companion.decodeWith(msg: co private fun com.google.protobuf.kotlin.FieldInternal.computeSize(): Int { var __result = 0 - if (com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN != kind) { + if (kind != com.google.protobuf.kotlin.Field.Kind.TYPE_UNKNOWN) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(kind.number)) } - if (com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN != cardinality) { + if (cardinality != com.google.protobuf.kotlin.Field.Cardinality.CARDINALITY_UNKNOWN) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(cardinality.number)) } @@ -576,7 +576,7 @@ public fun com.google.protobuf.kotlin.EnumInternal.encodeWith(encoder: kotlinx.r encoder.writeMessage(fieldNr = 4, value = sourceContext.asInternal()) { encodeWith(it) } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { encoder.writeEnum(fieldNr = 5, value = syntax.number) } @@ -650,7 +650,7 @@ private fun com.google.protobuf.kotlin.EnumInternal.computeSize(): Int { __result += sourceContext.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2 != syntax) { + if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(5, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(syntax.number)) } diff --git a/protobuf/protobuf-core/src/commonTest/proto/all_primitives.proto b/protobuf/protobuf-core/src/commonTest/proto/all_primitives.proto index e9afd1266..84c3a9f07 100644 --- a/protobuf/protobuf-core/src/commonTest/proto/all_primitives.proto +++ b/protobuf/protobuf-core/src/commonTest/proto/all_primitives.proto @@ -18,4 +18,6 @@ message AllPrimitives { optional bool bool = 13; optional string string = 14; optional bytes bytes = 15; + string requiredString = 16; + bytes requiredBytes = 17; } diff --git a/protobuf/protobuf-core/src/commonTest/proto/default.proto b/protobuf/protobuf-core/src/commonTest/proto/default.proto new file mode 100644 index 000000000..47748eef0 --- /dev/null +++ b/protobuf/protobuf-core/src/commonTest/proto/default.proto @@ -0,0 +1,32 @@ +syntax = "proto2"; + +// https://protobuf.dev/programming-guides/proto2/#default +message WithDefaults { + optional double double = 1 [default = 2.0]; + optional float float = 2 [default = 2.0]; + optional int32 int32 = 3 [default = 2]; + optional int64 int64 = 4 [default = 2]; + optional uint32 uint32 = 5 [default = 2]; + optional uint64 uint64 = 6 [default = 2]; + optional sint32 sint32 = 7 [default = 2]; + optional sint64 sint64 = 8 [default = 2]; + optional fixed32 fixed32 = 9 [default = 2]; + optional fixed64 fixed64 = 10 [default = 2]; + optional sfixed32 sfixed32 = 11 [default = 2]; + optional sfixed64 sfixed64 = 12 [default = 2]; + optional bool bool = 13 [default = true]; + optional string string = 14 [default = "str"]; + optional bytes bytes = 15 [default = "bytes"]; + + optional Custom1 enum1 = 16; + optional Custom2 enum2 = 17 [default = BAZ]; + + enum Custom1 { + FOO = 1; // default + } + + enum Custom2 { + BAR = 1; // default + BAZ = 2; // default + } +} diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/codeRequestToModel.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/codeRequestToModel.kt index adbcaca1c..820de6631 100644 --- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/codeRequestToModel.kt +++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/codeRequestToModel.kt @@ -74,7 +74,7 @@ private fun DescriptorProtos.FileDescriptorProto.toDescriptor( * * @return The fully qualified name represented as an instance of FqName, specific to the descriptor's context. */ -private fun Descriptors.GenericDescriptor.fqName(): FqName { +fun Descriptors.GenericDescriptor.fqName(): FqName { if (nameCache.containsKey(this)) return nameCache[this]!! val nameCapital = name.simpleProtoNameToKotlin(firstLetterUpper = true) val nameLower = name.simpleProtoNameToKotlin() diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt index 6b3c89229..2992e373c 100644 --- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt +++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/FieldType.kt @@ -53,8 +53,7 @@ sealed interface FieldType { override val defaultValue: String, override val wireType: WireType, override val isPackable: Boolean = true - ) : - FieldType { + ) : FieldType { STRING("String", "\"\"", WireType.LENGTH_DELIMITED, false), BYTES("ByteArray", "byteArrayOf()", WireType.LENGTH_DELIMITED, false), BOOL("Boolean", "false", WireType.VARINT), @@ -74,3 +73,20 @@ sealed interface FieldType { val fqName: FqName = FqName.Declaration(simpleName, FqName.Package.fromString("kotlin")) } } + +fun FieldType.scalarDefaultSuffix(): String = when (this) { + FieldType.IntegralType.BOOL -> "" + FieldType.IntegralType.FLOAT -> "f" + FieldType.IntegralType.DOUBLE -> "" + FieldType.IntegralType.INT32 -> "" + FieldType.IntegralType.INT64 -> "L" + FieldType.IntegralType.UINT32 -> "u" + FieldType.IntegralType.UINT64 -> "uL" + FieldType.IntegralType.FIXED32 -> "u" + FieldType.IntegralType.FIXED64 -> "uL" + FieldType.IntegralType.SINT32 -> "" + FieldType.IntegralType.SINT64 -> "L" + FieldType.IntegralType.SFIXED32 -> "" + FieldType.IntegralType.SFIXED64 -> "L" + else -> error("Unsupported scalar type: ${this::class}") +} diff --git a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/model.kt b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/model.kt index f60d463a9..9077791ce 100644 --- a/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/model.kt +++ b/protoc-gen/common/src/main/kotlin/kotlinx/rpc/protoc/gen/core/model/model.kt @@ -44,7 +44,11 @@ data class EnumDeclaration( ) { fun defaultEntry(): Entry { - return originalEntries.minBy { it.dec.number } + // In proto3 and editions: + // The first value must be a zero value, so that we can use 0 as a numeric default value + // In proto2: + // We use the first value as the default value + return originalEntries.first() } data class Entry( diff --git a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt index 2f5695f22..d0c7e7d6b 100644 --- a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt +++ b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt @@ -6,11 +6,14 @@ package kotlinx.rpc.protoc.gen +import com.google.protobuf.ByteString +import com.google.protobuf.Descriptors import kotlinx.rpc.protoc.gen.core.AModelToKotlinCommonGenerator import kotlinx.rpc.protoc.gen.core.CodeGenerator import kotlinx.rpc.protoc.gen.core.INTERNAL_RPC_API_ANNO import kotlinx.rpc.protoc.gen.core.PB_PKG import kotlinx.rpc.protoc.gen.core.WITH_CODEC_ANNO +import kotlinx.rpc.protoc.gen.core.fqName import kotlinx.rpc.protoc.gen.core.model.EnumDeclaration import kotlinx.rpc.protoc.gen.core.model.FieldDeclaration import kotlinx.rpc.protoc.gen.core.model.FieldType @@ -19,6 +22,7 @@ import kotlinx.rpc.protoc.gen.core.model.MessageDeclaration import kotlinx.rpc.protoc.gen.core.model.Model import kotlinx.rpc.protoc.gen.core.model.OneOfDeclaration import kotlinx.rpc.protoc.gen.core.model.WireType +import kotlinx.rpc.protoc.gen.core.model.scalarDefaultSuffix import org.slf4j.Logger class ModelToProtobufKotlinCommonGenerator( @@ -119,6 +123,7 @@ class ModelToProtobufKotlinCommonGenerator( ) { generatePresenceIndicesObject(declaration) + generateBytesDefaultsObject(declaration) property( name = "_size", @@ -143,7 +148,7 @@ class ModelToProtobufKotlinCommonGenerator( else -> { val fieldPresence = if (field.presenceIdx != null) "(PresenceIndices.${field.name})" else "" - "MsgFieldDelegate$fieldPresence { ${field.type.defaultValue} }" + "MsgFieldDelegate$fieldPresence { ${field.safeDefaultValue()} }" } } @@ -184,16 +189,50 @@ class ModelToProtobufKotlinCommonGenerator( } clazz("PresenceIndices", "private", declarationType = CodeGenerator.DeclarationType.Object) { - declaration.actualFields.forEachIndexed { i, field -> - if (field.presenceIdx != null) { - property( - field.name, - modifiers = "const", - value = field.presenceIdx.toString(), - type = "Int", - needsNewLineAfterDeclaration = i == declaration.actualFields.lastIndex, - ) + val fieldDeclarations = declaration.actualFields.filter { it.presenceIdx != null } + fieldDeclarations.forEachIndexed { i, field -> + property( + field.name, + modifiers = "const", + value = field.presenceIdx.toString(), + type = "Int", + needsNewLineAfterDeclaration = i == fieldDeclarations.lastIndex, + ) + } + } + } + + private fun CodeGenerator.generateBytesDefaultsObject(declaration: MessageDeclaration) { + val fieldDeclarations = declaration.actualFields + .filter { + it.type == FieldType.IntegralType.BYTES && + it.dec.hasDefaultValue() && + !(it.dec.defaultValue as ByteString).isEmpty + } + + if (fieldDeclarations.isEmpty()) { + return + } + + clazz("BytesDefaults", "private", declarationType = CodeGenerator.DeclarationType.Object) { + fieldDeclarations.forEachIndexed { i, field -> + val value = if (field.dec.hasDefaultValue()) { + val stringValue = (field.dec.defaultValue as ByteString).toString(Charsets.UTF_8) + if (stringValue.isNotEmpty()) { + "\"${stringValue}\".encodeToByteArray()" + } else { + FieldType.IntegralType.BYTES.defaultValue + } + } else { + FieldType.IntegralType.BYTES.defaultValue } + + property( + name = field.name, + value = value, + type = "ByteArray", + needsNewLineAfterDeclaration = i == fieldDeclarations.lastIndex, + ) } } } @@ -369,7 +408,7 @@ class ModelToProtobufKotlinCommonGenerator( } is FieldType.List -> if (isPacked) { - val conversion = if (fieldType.value is FieldType.Enum){ + val conversion = if (fieldType.value is FieldType.Enum) { ".map { ${(fieldType.value as FieldType.Enum).dec.name.safeFullName()}.fromNumber(it) }" } else { "" @@ -791,17 +830,55 @@ class ModelToProtobufKotlinCommonGenerator( private fun FieldDeclaration.notDefaultCheck(): String { return when (val fieldType = type) { - is FieldType.IntegralType -> when (fieldType) { - FieldType.IntegralType.BYTES, FieldType.IntegralType.STRING -> "$name.isNotEmpty()" - else -> "$name != ${fieldType.defaultValue}" + is FieldType.IntegralType -> { + val defaultValue = safeDefaultValue() + when { + fieldType == FieldType.IntegralType.STRING && + defaultValue == FieldType.IntegralType.STRING.defaultValue -> "$name.isNotEmpty()" + + fieldType == FieldType.IntegralType.STRING -> "!$name.contentEquals($defaultValue)" + + fieldType == FieldType.IntegralType.BYTES && + defaultValue == FieldType.IntegralType.BYTES.defaultValue -> "$name.isNotEmpty()" + + fieldType == FieldType.IntegralType.BYTES -> "!$name.contentEquals($defaultValue)" + + else -> "$name != $defaultValue" + } + } + + is FieldType.List, is FieldType.Map -> "$name.isNotEmpty()" + + is FieldType.Enum -> { + "$name != ${safeDefaultValue()}" } - is FieldType.List -> "$name.isNotEmpty()" is FieldType.Message -> error("Message fields should not be checked for default values.") + is FieldType.OneOf -> "null" + } + } + + private fun FieldDeclaration.safeDefaultValue(): String { + if (!dec.hasDefaultValue()) { + return type.defaultValue ?: error("No default value for field $name") + } + + return when (val value = dec.defaultValue) { + is String -> { + "\"$value\"" + } - is FieldType.Enum -> "${fieldType.defaultValue} != $name" + is ByteString -> { + "BytesDefaults.$name" + } - else -> "$name.isNotEmpty()" + is Descriptors.EnumValueDescriptor -> { + value.fqName().safeFullName() + } + + else -> { + "${value}${type.scalarDefaultSuffix()}" + } } } diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt index 4ea7c5c33..971356816 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt @@ -342,7 +342,7 @@ fun com.google.protobuf.conformance.ConformanceRequestInternal.checkRequiredFiel @kotlinx.rpc.internal.utils.InternalRpcApi fun com.google.protobuf.conformance.ConformanceRequestInternal.encodeWith(encoder: kotlinx.rpc.protobuf.internal.WireEncoder) { - if (com.google.protobuf.conformance.WireFormat.UNSPECIFIED != requestedOutputFormat) { + if (requestedOutputFormat != com.google.protobuf.conformance.WireFormat.UNSPECIFIED) { encoder.writeEnum(fieldNr = 3, value = requestedOutputFormat.number) } @@ -350,7 +350,7 @@ fun com.google.protobuf.conformance.ConformanceRequestInternal.encodeWith(encode encoder.writeString(fieldNr = 4, value = messageType) } - if (com.google.protobuf.conformance.TestCategory.UNSPECIFIED_TEST != testCategory) { + if (testCategory != com.google.protobuf.conformance.TestCategory.UNSPECIFIED_TEST) { encoder.writeEnum(fieldNr = 5, value = testCategory.number) } @@ -440,7 +440,7 @@ fun com.google.protobuf.conformance.ConformanceRequestInternal.Companion.decodeW private fun com.google.protobuf.conformance.ConformanceRequestInternal.computeSize(): Int { var __result = 0 - if (com.google.protobuf.conformance.WireFormat.UNSPECIFIED != requestedOutputFormat) { + if (requestedOutputFormat != com.google.protobuf.conformance.WireFormat.UNSPECIFIED) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(requestedOutputFormat.number)) } @@ -448,7 +448,7 @@ private fun com.google.protobuf.conformance.ConformanceRequestInternal.computeSi __result += kotlinx.rpc.protobuf.internal.WireSize.string(messageType).let { kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.conformance.TestCategory.UNSPECIFIED_TEST != testCategory) { + if (testCategory != com.google.protobuf.conformance.TestCategory.UNSPECIFIED_TEST) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(5, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(testCategory.number)) } diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt index 5cc526050..c868c5b44 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt @@ -48,7 +48,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.editions.pro override var optionalBytes: ByteArray by MsgFieldDelegate { byteArrayOf() } override var optionalNestedMessage: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedMessage by MsgFieldDelegate(PresenceIndices.optionalNestedMessage) { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.NestedMessageInternal() } override var optionalForeignMessage: com.google.protobuf_test_messages.editions.proto3.ForeignMessage by MsgFieldDelegate(PresenceIndices.optionalForeignMessage) { com.google.protobuf_test_messages.editions.proto3.ForeignMessageInternal() } - override var optionalNestedEnum: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG } + override var optionalNestedEnum: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO } override var optionalForeignEnum: com.google.protobuf_test_messages.editions.proto3.ForeignEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO } override var optionalAliasedEnum: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO } override var optionalStringPiece: String by MsgFieldDelegate { "" } @@ -412,7 +412,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.editions.pro override val _size: Int by lazy { computeSize() } var key: String by MsgFieldDelegate { "" } - var value: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG } + var value: com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO } @kotlinx.rpc.internal.utils.InternalRpcApi companion object @@ -815,15 +815,15 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal encoder.writeMessage(fieldNr = 19, value = optionalForeignMessage.asInternal()) { encodeWith(it) } } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG != optionalNestedEnum) { + if (optionalNestedEnum != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO) { encoder.writeEnum(fieldNr = 21, value = optionalNestedEnum.number) } - if (com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO != optionalForeignEnum) { + if (optionalForeignEnum != com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO) { encoder.writeEnum(fieldNr = 22, value = optionalForeignEnum.number) } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO != optionalAliasedEnum) { + if (optionalAliasedEnum != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO) { encoder.writeEnum(fieldNr = 23, value = optionalAliasedEnum.number) } @@ -1417,7 +1417,7 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal encoder.writeMessage(fieldNr = 306, value = optionalValue.asInternal()) { encodeWith(it) } } - if (com.google.protobuf.kotlin.NullValue.NULL_VALUE != optionalNullValue) { + if (optionalNullValue != com.google.protobuf.kotlin.NullValue.NULL_VALUE) { encoder.writeEnum(fieldNr = 307, value = optionalNullValue.number) } @@ -2657,15 +2657,15 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 __result += optionalForeignMessage.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(19, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG != optionalNestedEnum) { + if (optionalNestedEnum != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(21, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalNestedEnum.number)) } - if (com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO != optionalForeignEnum) { + if (optionalForeignEnum != com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(22, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalForeignEnum.number)) } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO != optionalAliasedEnum) { + if (optionalAliasedEnum != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(23, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalAliasedEnum.number)) } @@ -3163,7 +3163,7 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 __result += optionalValue.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(306, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.kotlin.NullValue.NULL_VALUE != optionalNullValue) { + if (optionalNullValue != com.google.protobuf.kotlin.NullValue.NULL_VALUE) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(307, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalNullValue.number)) } @@ -4492,7 +4492,7 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal encoder.writeString(fieldNr = 1, value = key) } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG != value) { + if (value != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO) { encoder.writeEnum(fieldNr = 2, value = value.number) } } @@ -4526,7 +4526,7 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 __result += kotlinx.rpc.protobuf.internal.WireSize.string(key).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.NEG != value) { + if (value != com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3.NestedEnum.FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(value.number)) } @@ -4549,7 +4549,7 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal encoder.writeString(fieldNr = 1, value = key) } - if (com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO != value) { + if (value != com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO) { encoder.writeEnum(fieldNr = 2, value = value.number) } } @@ -4583,7 +4583,7 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 __result += kotlinx.rpc.protobuf.internal.WireSize.string(key).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO != value) { + if (value != com.google.protobuf_test_messages.editions.proto3.ForeignEnum.FOREIGN_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(value.number)) } diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt index bd9c57aae..84923c75c 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt @@ -48,7 +48,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.proto3.TestA override var optionalBytes: ByteArray by MsgFieldDelegate { byteArrayOf() } override var optionalNestedMessage: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedMessage by MsgFieldDelegate(PresenceIndices.optionalNestedMessage) { com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.NestedMessageInternal() } override var optionalForeignMessage: com.google.protobuf_test_messages.proto3.ForeignMessage by MsgFieldDelegate(PresenceIndices.optionalForeignMessage) { com.google.protobuf_test_messages.proto3.ForeignMessageInternal() } - override var optionalNestedEnum: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG } + override var optionalNestedEnum: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO } override var optionalForeignEnum: com.google.protobuf_test_messages.proto3.ForeignEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO } override var optionalAliasedEnum: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO } override var optionalStringPiece: String by MsgFieldDelegate { "" } @@ -412,7 +412,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.proto3.TestA override val _size: Int by lazy { computeSize() } var key: String by MsgFieldDelegate { "" } - var value: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG } + var value: com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum by MsgFieldDelegate { com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO } @kotlinx.rpc.internal.utils.InternalRpcApi companion object @@ -815,15 +815,15 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.encodeWi encoder.writeMessage(fieldNr = 19, value = optionalForeignMessage.asInternal()) { encodeWith(it) } } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG != optionalNestedEnum) { + if (optionalNestedEnum != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO) { encoder.writeEnum(fieldNr = 21, value = optionalNestedEnum.number) } - if (com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO != optionalForeignEnum) { + if (optionalForeignEnum != com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO) { encoder.writeEnum(fieldNr = 22, value = optionalForeignEnum.number) } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO != optionalAliasedEnum) { + if (optionalAliasedEnum != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO) { encoder.writeEnum(fieldNr = 23, value = optionalAliasedEnum.number) } @@ -1417,7 +1417,7 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.encodeWi encoder.writeMessage(fieldNr = 306, value = optionalValue.asInternal()) { encodeWith(it) } } - if (com.google.protobuf.kotlin.NullValue.NULL_VALUE != optionalNullValue) { + if (optionalNullValue != com.google.protobuf.kotlin.NullValue.NULL_VALUE) { encoder.writeEnum(fieldNr = 307, value = optionalNullValue.number) } @@ -2657,15 +2657,15 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. __result += optionalForeignMessage.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(19, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG != optionalNestedEnum) { + if (optionalNestedEnum != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(21, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalNestedEnum.number)) } - if (com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO != optionalForeignEnum) { + if (optionalForeignEnum != com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(22, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalForeignEnum.number)) } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO != optionalAliasedEnum) { + if (optionalAliasedEnum != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.AliasedEnum.ALIAS_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(23, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalAliasedEnum.number)) } @@ -3163,7 +3163,7 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. __result += optionalValue.asInternal()._size.let { kotlinx.rpc.protobuf.internal.WireSize.tag(306, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf.kotlin.NullValue.NULL_VALUE != optionalNullValue) { + if (optionalNullValue != com.google.protobuf.kotlin.NullValue.NULL_VALUE) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(307, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(optionalNullValue.number)) } @@ -4492,7 +4492,7 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin encoder.writeString(fieldNr = 1, value = key) } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG != value) { + if (value != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO) { encoder.writeEnum(fieldNr = 2, value = value.number) } } @@ -4526,7 +4526,7 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. __result += kotlinx.rpc.protobuf.internal.WireSize.string(key).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.NEG != value) { + if (value != com.google.protobuf_test_messages.proto3.TestAllTypesProto3.NestedEnum.FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(value.number)) } @@ -4549,7 +4549,7 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin encoder.writeString(fieldNr = 1, value = key) } - if (com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO != value) { + if (value != com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO) { encoder.writeEnum(fieldNr = 2, value = value.number) } } @@ -4583,7 +4583,7 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. __result += kotlinx.rpc.protobuf.internal.WireSize.string(key).let { kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) + kotlinx.rpc.protobuf.internal.WireSize.int32(it) + it } } - if (com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO != value) { + if (value != com.google.protobuf_test_messages.proto3.ForeignEnum.FOREIGN_FOO) { __result += (kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.VARINT) + kotlinx.rpc.protobuf.internal.WireSize.enum(value.number)) } diff --git a/tests/protobuf-conformance/src/main/kotlin/kotlinx/rpc/protoc/gen/test/runner/runner.kt b/tests/protobuf-conformance/src/main/kotlin/kotlinx/rpc/protoc/gen/test/runner/runner.kt index 9c0363fc3..e2146404f 100644 --- a/tests/protobuf-conformance/src/main/kotlin/kotlinx/rpc/protoc/gen/test/runner/runner.kt +++ b/tests/protobuf-conformance/src/main/kotlin/kotlinx/rpc/protoc/gen/test/runner/runner.kt @@ -11,6 +11,7 @@ import kotlin.io.path.createFile import kotlin.io.path.createParentDirectories import kotlin.io.path.deleteIfExists import kotlin.io.path.readLines +import kotlin.properties.Delegates class RunResult( val exitCode: Int, @@ -30,8 +31,9 @@ fun execConformanceTestRunner( val testNameFilter = testName?.let { listOf("--test", it) } ?: emptyList() + var process: Process by Delegates.notNull() return runCatching { - val process = ProcessBuilder( + process = ProcessBuilder( CONFORMANCE_EXECUTABLE_PATH, *testNameFilter.toTypedArray(), "--maximum_edition", "MAX", @@ -43,14 +45,23 @@ fun execConformanceTestRunner( executable, ).redirectError(errorStream.toFile()) .redirectOutput(stdoutStream.toFile()) + .start() - val exitCode = process.start().waitFor() + Runtime.getRuntime().addShutdownHook(Thread { + process.destroy() + }) + + val exitCode = process.waitFor() RunResult( exitCode = exitCode, stdout = stdoutStream.readLines(), stderr = errorStream.readLines(), ) + }.onFailure { + if (process.isAlive) { + process.destroy() + } } } From 6ad8fd72231639b7ccff01375797636da0529053 Mon Sep 17 00:00:00 2001 From: Alexander Sysoev Date: Tue, 19 Aug 2025 12:29:53 +0200 Subject: [PATCH 3/5] Fix size calculation for repeated fields --- .../protobuf/kotlin/_rpc_internal/Api.kt | 8 +-- .../kotlin/_rpc_internal/FieldMask.kt | 2 +- .../protobuf/kotlin/_rpc_internal/Struct.kt | 2 +- .../protobuf/kotlin/_rpc_internal/Type.kt | 14 ++-- .../ModelToProtobufKotlinCommonGenerator.kt | 2 +- .../conformance/_rpc_internal/Conformance.kt | 2 +- .../TestMessagesProto3Editions.kt | 72 +++++++++---------- .../_rpc_internal/TestMessagesProto3.kt | 72 +++++++++---------- 8 files changed, 87 insertions(+), 87 deletions(-) diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt index 9dcd9cd07..1445ea446 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt @@ -256,11 +256,11 @@ private fun com.google.protobuf.kotlin.ApiInternal.computeSize(): Int { } if (methods.isNotEmpty()) { - __result = methods.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += methods.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (version.isNotEmpty()) { @@ -272,7 +272,7 @@ private fun com.google.protobuf.kotlin.ApiInternal.computeSize(): Int { } if (mixins.isNotEmpty()) { - __result = mixins.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += mixins.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { @@ -396,7 +396,7 @@ private fun com.google.protobuf.kotlin.MethodInternal.computeSize(): Int { } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(6, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (syntax != com.google.protobuf.kotlin.Syntax.SYNTAX_PROTO2) { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt index 6d5397459..e8ee56f8e 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt @@ -81,7 +81,7 @@ public fun com.google.protobuf.kotlin.FieldMaskInternal.Companion.decodeWith(msg private fun com.google.protobuf.kotlin.FieldMaskInternal.computeSize(): Int { var __result = 0 if (paths.isNotEmpty()) { - __result = paths.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += paths.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } return __result diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt index 3bf04d436..834bfc8b7 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt @@ -375,7 +375,7 @@ public fun com.google.protobuf.kotlin.ListValueInternal.Companion.decodeWith(msg private fun com.google.protobuf.kotlin.ListValueInternal.computeSize(): Int { var __result = 0 if (values.isNotEmpty()) { - __result = values.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += values.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(1, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } return __result diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt index efa9b8bf1..7a15f91f0 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt @@ -347,15 +347,15 @@ private fun com.google.protobuf.kotlin.TypeInternal.computeSize(): Int { } if (fields.isNotEmpty()) { - __result = fields.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += fields.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (oneofs.isNotEmpty()) { - __result = oneofs.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += oneofs.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(4, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (presenceMask[0]) { @@ -519,7 +519,7 @@ private fun com.google.protobuf.kotlin.FieldInternal.computeSize(): Int { } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(9, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(9, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (jsonName.isNotEmpty()) { @@ -639,11 +639,11 @@ private fun com.google.protobuf.kotlin.EnumInternal.computeSize(): Int { } if (enumvalue.isNotEmpty()) { - __result = enumvalue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += enumvalue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (presenceMask[0]) { @@ -731,7 +731,7 @@ private fun com.google.protobuf.kotlin.EnumValueInternal.computeSize(): Int { } if (options.isNotEmpty()) { - __result = options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += options.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(3, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } return __result diff --git a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt index d0c7e7d6b..88e1f950c 100644 --- a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt +++ b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt @@ -734,7 +734,7 @@ class ModelToProtobufKotlinCommonGenerator( is FieldType.List -> when { // packed fields also have the tag + len field.dec.isPacked -> code("__result += $valueSize.let { $tagSize + ${int32SizeCall("it")} + it }") - else -> code("__result = $valueSize") + else -> code("__result += $valueSize") } is FieldType.Message, diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt index 971356816..a3c7173a7 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt @@ -321,7 +321,7 @@ fun com.google.protobuf.conformance.FailureSetInternal.Companion.decodeWith(msg: private fun com.google.protobuf.conformance.FailureSetInternal.computeSize(): Int { var __result = 0 if (test.isNotEmpty()) { - __result = test.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += test.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(2, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } return __result diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt index c868c5b44..24e0e96e5 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt @@ -2734,19 +2734,19 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 } if (repeatedString.isNotEmpty()) { - __result = repeatedString.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(44, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedString.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(44, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedBytes.isNotEmpty()) { - __result = repeatedBytes.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bytes(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(45, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBytes.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bytes(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(45, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedNestedMessage.isNotEmpty()) { - __result = repeatedNestedMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(48, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedNestedMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(48, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedForeignMessage.isNotEmpty()) { - __result = repeatedForeignMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(49, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedForeignMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(49, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedNestedEnum.isNotEmpty()) { @@ -2758,11 +2758,11 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 } if (repeatedStringPiece.isNotEmpty()) { - __result = repeatedStringPiece.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(54, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStringPiece.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(54, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedCord.isNotEmpty()) { - __result = repeatedCord.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(55, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedCord.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(55, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (packedInt32.isNotEmpty()) { @@ -2822,59 +2822,59 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 } if (unpackedInt32.isNotEmpty()) { - __result = unpackedInt32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(89, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedInt32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(89, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedInt64.isNotEmpty()) { - __result = unpackedInt64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(90, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedInt64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(90, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedUint32.isNotEmpty()) { - __result = unpackedUint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(91, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedUint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(91, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedUint64.isNotEmpty()) { - __result = unpackedUint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(92, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedUint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(92, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedSint32.isNotEmpty()) { - __result = unpackedSint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(93, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedSint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(93, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedSint64.isNotEmpty()) { - __result = unpackedSint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(94, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedSint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(94, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedFixed32.isNotEmpty()) { - __result = unpackedFixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(95, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedFixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(95, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedFixed64.isNotEmpty()) { - __result = unpackedFixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(96, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedFixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(96, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedSfixed32.isNotEmpty()) { - __result = unpackedSfixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(97, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedSfixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(97, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedSfixed64.isNotEmpty()) { - __result = unpackedSfixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(98, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedSfixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(98, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedFloat.isNotEmpty()) { - __result = unpackedFloat.sumOf { kotlinx.rpc.protobuf.internal.WireSize.float(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(99, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedFloat.sumOf { kotlinx.rpc.protobuf.internal.WireSize.float(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(99, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedDouble.isNotEmpty()) { - __result = unpackedDouble.sumOf { kotlinx.rpc.protobuf.internal.WireSize.double(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(100, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedDouble.sumOf { kotlinx.rpc.protobuf.internal.WireSize.double(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(100, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedBool.isNotEmpty()) { - __result = unpackedBool.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bool(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(101, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedBool.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bool(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(101, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedNestedEnum.isNotEmpty()) { - __result = unpackedNestedEnum.sumOf { kotlinx.rpc.protobuf.internal.WireSize.enum(it.number) + kotlinx.rpc.protobuf.internal.WireSize.tag(102, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedNestedEnum.sumOf { kotlinx.rpc.protobuf.internal.WireSize.enum(it.number) + kotlinx.rpc.protobuf.internal.WireSize.tag(102, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (mapInt32Int32.isNotEmpty()) { @@ -3104,39 +3104,39 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 } if (repeatedBoolWrapper.isNotEmpty()) { - __result = repeatedBoolWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(211, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBoolWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(211, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedInt32Wrapper.isNotEmpty()) { - __result = repeatedInt32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(212, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedInt32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(212, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedInt64Wrapper.isNotEmpty()) { - __result = repeatedInt64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(213, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedInt64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(213, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedUint32Wrapper.isNotEmpty()) { - __result = repeatedUint32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(214, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedUint32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(214, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedUint64Wrapper.isNotEmpty()) { - __result = repeatedUint64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(215, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedUint64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(215, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedFloatWrapper.isNotEmpty()) { - __result = repeatedFloatWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(216, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedFloatWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(216, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedDoubleWrapper.isNotEmpty()) { - __result = repeatedDoubleWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(217, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedDoubleWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(217, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedStringWrapper.isNotEmpty()) { - __result = repeatedStringWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(218, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStringWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(218, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedBytesWrapper.isNotEmpty()) { - __result = repeatedBytesWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(219, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBytesWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(219, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (presenceMask[12]) { @@ -3168,31 +3168,31 @@ private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3 } if (repeatedDuration.isNotEmpty()) { - __result = repeatedDuration.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(311, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedDuration.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(311, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedTimestamp.isNotEmpty()) { - __result = repeatedTimestamp.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(312, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedTimestamp.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(312, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedFieldmask.isNotEmpty()) { - __result = repeatedFieldmask.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(313, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedFieldmask.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(313, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedStruct.isNotEmpty()) { - __result = repeatedStruct.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(324, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStruct.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(324, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedAny.isNotEmpty()) { - __result = repeatedAny.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(315, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedAny.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(315, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedValue.isNotEmpty()) { - __result = repeatedValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(316, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(316, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedListValue.isNotEmpty()) { - __result = repeatedListValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(317, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedListValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(317, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (fieldname1 != 0) { diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt index 84923c75c..1bdaddf9b 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt @@ -2734,19 +2734,19 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. } if (repeatedString.isNotEmpty()) { - __result = repeatedString.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(44, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedString.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(44, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedBytes.isNotEmpty()) { - __result = repeatedBytes.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bytes(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(45, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBytes.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bytes(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(45, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedNestedMessage.isNotEmpty()) { - __result = repeatedNestedMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(48, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedNestedMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(48, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedForeignMessage.isNotEmpty()) { - __result = repeatedForeignMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(49, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedForeignMessage.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(49, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedNestedEnum.isNotEmpty()) { @@ -2758,11 +2758,11 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. } if (repeatedStringPiece.isNotEmpty()) { - __result = repeatedStringPiece.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(54, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStringPiece.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(54, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedCord.isNotEmpty()) { - __result = repeatedCord.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(55, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedCord.sumOf { kotlinx.rpc.protobuf.internal.WireSize.string(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(55, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (packedInt32.isNotEmpty()) { @@ -2822,59 +2822,59 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. } if (unpackedInt32.isNotEmpty()) { - __result = unpackedInt32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(89, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedInt32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(89, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedInt64.isNotEmpty()) { - __result = unpackedInt64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(90, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedInt64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.int64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(90, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedUint32.isNotEmpty()) { - __result = unpackedUint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(91, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedUint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(91, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedUint64.isNotEmpty()) { - __result = unpackedUint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(92, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedUint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.uInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(92, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedSint32.isNotEmpty()) { - __result = unpackedSint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(93, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedSint32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(93, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedSint64.isNotEmpty()) { - __result = unpackedSint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(94, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedSint64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sInt64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(94, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedFixed32.isNotEmpty()) { - __result = unpackedFixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(95, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedFixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(95, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedFixed64.isNotEmpty()) { - __result = unpackedFixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(96, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedFixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.fixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(96, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedSfixed32.isNotEmpty()) { - __result = unpackedSfixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(97, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedSfixed32.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed32(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(97, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedSfixed64.isNotEmpty()) { - __result = unpackedSfixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(98, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedSfixed64.sumOf { kotlinx.rpc.protobuf.internal.WireSize.sFixed64(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(98, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedFloat.isNotEmpty()) { - __result = unpackedFloat.sumOf { kotlinx.rpc.protobuf.internal.WireSize.float(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(99, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } + __result += unpackedFloat.sumOf { kotlinx.rpc.protobuf.internal.WireSize.float(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(99, kotlinx.rpc.protobuf.internal.WireType.FIXED32) } } if (unpackedDouble.isNotEmpty()) { - __result = unpackedDouble.sumOf { kotlinx.rpc.protobuf.internal.WireSize.double(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(100, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } + __result += unpackedDouble.sumOf { kotlinx.rpc.protobuf.internal.WireSize.double(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(100, kotlinx.rpc.protobuf.internal.WireType.FIXED64) } } if (unpackedBool.isNotEmpty()) { - __result = unpackedBool.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bool(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(101, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedBool.sumOf { kotlinx.rpc.protobuf.internal.WireSize.bool(it) + kotlinx.rpc.protobuf.internal.WireSize.tag(101, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (unpackedNestedEnum.isNotEmpty()) { - __result = unpackedNestedEnum.sumOf { kotlinx.rpc.protobuf.internal.WireSize.enum(it.number) + kotlinx.rpc.protobuf.internal.WireSize.tag(102, kotlinx.rpc.protobuf.internal.WireType.VARINT) } + __result += unpackedNestedEnum.sumOf { kotlinx.rpc.protobuf.internal.WireSize.enum(it.number) + kotlinx.rpc.protobuf.internal.WireSize.tag(102, kotlinx.rpc.protobuf.internal.WireType.VARINT) } } if (mapInt32Int32.isNotEmpty()) { @@ -3104,39 +3104,39 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. } if (repeatedBoolWrapper.isNotEmpty()) { - __result = repeatedBoolWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(211, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBoolWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(211, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedInt32Wrapper.isNotEmpty()) { - __result = repeatedInt32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(212, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedInt32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(212, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedInt64Wrapper.isNotEmpty()) { - __result = repeatedInt64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(213, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedInt64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(213, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedUint32Wrapper.isNotEmpty()) { - __result = repeatedUint32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(214, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedUint32Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(214, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedUint64Wrapper.isNotEmpty()) { - __result = repeatedUint64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(215, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedUint64Wrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(215, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedFloatWrapper.isNotEmpty()) { - __result = repeatedFloatWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(216, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedFloatWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(216, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedDoubleWrapper.isNotEmpty()) { - __result = repeatedDoubleWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(217, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedDoubleWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(217, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedStringWrapper.isNotEmpty()) { - __result = repeatedStringWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(218, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStringWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(218, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedBytesWrapper.isNotEmpty()) { - __result = repeatedBytesWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(219, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedBytesWrapper.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(219, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (presenceMask[12]) { @@ -3168,31 +3168,31 @@ private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal. } if (repeatedDuration.isNotEmpty()) { - __result = repeatedDuration.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(311, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedDuration.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(311, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedTimestamp.isNotEmpty()) { - __result = repeatedTimestamp.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(312, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedTimestamp.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(312, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedFieldmask.isNotEmpty()) { - __result = repeatedFieldmask.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(313, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedFieldmask.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(313, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedStruct.isNotEmpty()) { - __result = repeatedStruct.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(324, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedStruct.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(324, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedAny.isNotEmpty()) { - __result = repeatedAny.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(315, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedAny.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(315, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedValue.isNotEmpty()) { - __result = repeatedValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(316, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(316, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (repeatedListValue.isNotEmpty()) { - __result = repeatedListValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(317, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } + __result += repeatedListValue.sumOf { it.asInternal()._size + kotlinx.rpc.protobuf.internal.WireSize.tag(317, kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED) } } if (fieldname1 != 0) { From f3d55702d747c0b406ded4f0dc2d723dbcceb147 Mon Sep 17 00:00:00 2001 From: Alexander Sysoev Date: Tue, 19 Aug 2025 14:01:15 +0200 Subject: [PATCH 4/5] Fix CI setups --- .../src/main/kotlin/util/other/localProperties.kt | 9 ++++++++- tests/protobuf-conformance/build.gradle.kts | 12 ++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gradle-conventions/src/main/kotlin/util/other/localProperties.kt b/gradle-conventions/src/main/kotlin/util/other/localProperties.kt index 1c41fdf92..20597626f 100644 --- a/gradle-conventions/src/main/kotlin/util/other/localProperties.kt +++ b/gradle-conventions/src/main/kotlin/util/other/localProperties.kt @@ -10,6 +10,7 @@ import org.gradle.kotlin.dsl.provideDelegate import java.util.Properties import java.util.concurrent.atomic.AtomicReference import kotlin.io.path.Path +import kotlin.io.path.exists import kotlin.io.path.inputStream private val ref = AtomicReference() @@ -19,7 +20,13 @@ fun Project.localProperties(): Properties { ref.compareAndSet(null, Properties().apply { val globalRootDir: String by extra - load(Path(globalRootDir, "local.properties").inputStream()) + val filepath = Path(globalRootDir, "local.properties") + + if (!filepath.exists()) { + return@apply + } + + load(filepath.inputStream()) }) } diff --git a/tests/protobuf-conformance/build.gradle.kts b/tests/protobuf-conformance/build.gradle.kts index f4d723337..37419dd68 100644 --- a/tests/protobuf-conformance/build.gradle.kts +++ b/tests/protobuf-conformance/build.gradle.kts @@ -112,7 +112,6 @@ tasks.register("runConformanceTest") { mainClass.set("kotlinx.rpc.protoc.gen.test.RunConformanceTestKt") val protoscope = localProperties().getProperty("protoscope_path") - ?: throw GradleException("protoscope_path property is not set. Run ./setup_protoscope.sh") environment("PROTOSCOPE_PATH", protoscope) @@ -130,15 +129,8 @@ tasks.register("runConformanceTest") { ) doFirst { - if (!File(protoscope).exists()) { - throw GradleException( - """ - Protoscope is not found. Use the following command to install it: - - $ brew install go - $ go install github.com/protocolbuffers/protoscope/cmd/protoscope...@latest - """.trimIndent() - ) + if (protoscope == null || !File(protoscope).exists()) { + throw GradleException("protoscope_path property is not set. Run ./setup_protoscope.sh") } } } From 6abe3b6d5c35c170608f18df3eb7c51aa69c41dc Mon Sep 17 00:00:00 2001 From: Alexander Sysoev Date: Wed, 20 Aug 2025 12:14:18 +0200 Subject: [PATCH 5/5] Rollback `code("msg.checkRequiredFields()")` change --- .../protobuf/kotlin/_rpc_internal/Any.kt | 3 +- .../protobuf/kotlin/_rpc_internal/Api.kt | 9 ++-- .../protobuf/kotlin/_rpc_internal/Duration.kt | 3 +- .../protobuf/kotlin/_rpc_internal/Empty.kt | 3 +- .../kotlin/_rpc_internal/FieldMask.kt | 3 +- .../kotlin/_rpc_internal/SourceContext.kt | 3 +- .../protobuf/kotlin/_rpc_internal/Struct.kt | 11 ++-- .../kotlin/_rpc_internal/Timestamp.kt | 3 +- .../protobuf/kotlin/_rpc_internal/Type.kt | 15 ++---- .../protobuf/kotlin/_rpc_internal/Wrappers.kt | 27 ++++------ .../ModelToProtobufKotlinCommonGenerator.kt | 3 +- .../conformance/_rpc_internal/Conformance.kt | 15 ++---- .../TestMessagesProto3Editions.kt | 53 ++----------------- .../_rpc_internal/TestMessagesProto3.kt | 53 ++----------------- 14 files changed, 42 insertions(+), 162 deletions(-) diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt index b533bbbfa..61f9897aa 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Any.kt @@ -30,6 +30,7 @@ public class AnyInternal: com.google.protobuf.kotlin.Any, kotlinx.rpc.protobuf.i kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.AnyInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -80,8 +81,6 @@ public fun com.google.protobuf.kotlin.AnyInternal.Companion.decodeWith(msg: com. } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.AnyInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt index 1445ea446..66760e11f 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Api.kt @@ -39,6 +39,7 @@ public class ApiInternal: com.google.protobuf.kotlin.Api, kotlinx.rpc.protobuf.i kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.ApiInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -78,6 +79,7 @@ public class MethodInternal: com.google.protobuf.kotlin.Method, kotlinx.rpc.prot kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.MethodInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -112,6 +114,7 @@ public class MixinInternal: com.google.protobuf.kotlin.Mixin, kotlinx.rpc.protob kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.MixinInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -245,8 +248,6 @@ public fun com.google.protobuf.kotlin.ApiInternal.Companion.decodeWith(msg: com. } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.ApiInternal.computeSize(): Int { @@ -369,8 +370,6 @@ public fun com.google.protobuf.kotlin.MethodInternal.Companion.decodeWith(msg: c } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.MethodInternal.computeSize(): Int { @@ -446,8 +445,6 @@ public fun com.google.protobuf.kotlin.MixinInternal.Companion.decodeWith(msg: co } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.MixinInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt index d651a2788..a21fd44ae 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Duration.kt @@ -30,6 +30,7 @@ public class DurationInternal: com.google.protobuf.kotlin.Duration, kotlinx.rpc. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.DurationInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -80,8 +81,6 @@ public fun com.google.protobuf.kotlin.DurationInternal.Companion.decodeWith(msg: } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.DurationInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt index 319398332..710388e37 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Empty.kt @@ -27,6 +27,7 @@ public class EmptyInternal: com.google.protobuf.kotlin.Empty, kotlinx.rpc.protob kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.EmptyInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -63,8 +64,6 @@ public fun com.google.protobuf.kotlin.EmptyInternal.Companion.decodeWith(msg: co } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.EmptyInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt index e8ee56f8e..da3284fca 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/FieldMask.kt @@ -29,6 +29,7 @@ public class FieldMaskInternal: com.google.protobuf.kotlin.FieldMask, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.FieldMaskInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -74,8 +75,6 @@ public fun com.google.protobuf.kotlin.FieldMaskInternal.Companion.decodeWith(msg } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.FieldMaskInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt index 3dab051aa..4c79763a7 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/SourceContext.kt @@ -29,6 +29,7 @@ public class SourceContextInternal: com.google.protobuf.kotlin.SourceContext, ko kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.SourceContextInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -71,8 +72,6 @@ public fun com.google.protobuf.kotlin.SourceContextInternal.Companion.decodeWith } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.SourceContextInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt index 834bfc8b7..4f69c5022 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Struct.kt @@ -44,6 +44,7 @@ public class StructInternal: com.google.protobuf.kotlin.Struct, kotlinx.rpc.prot kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.StructInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -77,6 +78,7 @@ public class ValueInternal: com.google.protobuf.kotlin.Value, kotlinx.rpc.protob kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.ValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -110,6 +112,7 @@ public class ListValueInternal: com.google.protobuf.kotlin.ListValue, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.ListValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -178,8 +181,6 @@ public fun com.google.protobuf.kotlin.StructInternal.Companion.decodeWith(msg: c } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.StructInternal.computeSize(): Int { @@ -292,8 +293,6 @@ public fun com.google.protobuf.kotlin.ValueInternal.Companion.decodeWith(msg: co } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.ValueInternal.computeSize(): Int { @@ -368,8 +367,6 @@ public fun com.google.protobuf.kotlin.ListValueInternal.Companion.decodeWith(msg } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.ListValueInternal.computeSize(): Int { @@ -428,8 +425,6 @@ public fun com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal.Compani } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.StructInternal.FieldsEntryInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt index 02dae866f..c3b2f51ea 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Timestamp.kt @@ -30,6 +30,7 @@ public class TimestampInternal: com.google.protobuf.kotlin.Timestamp, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.TimestampInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -80,8 +81,6 @@ public fun com.google.protobuf.kotlin.TimestampInternal.Companion.decodeWith(msg } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.TimestampInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt index 7a15f91f0..39e19e2d2 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Type.kt @@ -39,6 +39,7 @@ public class TypeInternal: com.google.protobuf.kotlin.Type, kotlinx.rpc.protobuf kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.TypeInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -81,6 +82,7 @@ public class FieldInternal: com.google.protobuf.kotlin.Field, kotlinx.rpc.protob kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.FieldInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -123,6 +125,7 @@ public class EnumInternal: com.google.protobuf.kotlin.Enum, kotlinx.rpc.protobuf kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.EnumInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -158,6 +161,7 @@ public class EnumValueInternal: com.google.protobuf.kotlin.EnumValue, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.EnumValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -196,6 +200,7 @@ public class OptionInternal: com.google.protobuf.kotlin.Option, kotlinx.rpc.prot kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.OptionInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -336,8 +341,6 @@ public fun com.google.protobuf.kotlin.TypeInternal.Companion.decodeWith(msg: com } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.TypeInternal.computeSize(): Int { @@ -484,8 +487,6 @@ public fun com.google.protobuf.kotlin.FieldInternal.Companion.decodeWith(msg: co } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.FieldInternal.computeSize(): Int { @@ -628,8 +629,6 @@ public fun com.google.protobuf.kotlin.EnumInternal.Companion.decodeWith(msg: com } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.EnumInternal.computeSize(): Int { @@ -716,8 +715,6 @@ public fun com.google.protobuf.kotlin.EnumValueInternal.Companion.decodeWith(msg } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.EnumValueInternal.computeSize(): Int { @@ -784,8 +781,6 @@ public fun com.google.protobuf.kotlin.OptionInternal.Companion.decodeWith(msg: c } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.OptionInternal.computeSize(): Int { diff --git a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt index 9a885691c..19f862504 100644 --- a/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt +++ b/protobuf/protobuf-core/src/commonMain/generated-code/kotlin-multiplatform/com/google/protobuf/kotlin/_rpc_internal/Wrappers.kt @@ -29,6 +29,7 @@ public class DoubleValueInternal: com.google.protobuf.kotlin.DoubleValue, kotlin kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.DoubleValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -62,6 +63,7 @@ public class FloatValueInternal: com.google.protobuf.kotlin.FloatValue, kotlinx. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.FloatValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -95,6 +97,7 @@ public class Int64ValueInternal: com.google.protobuf.kotlin.Int64Value, kotlinx. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.Int64ValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -128,6 +131,7 @@ public class UInt64ValueInternal: com.google.protobuf.kotlin.UInt64Value, kotlin kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.UInt64ValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -161,6 +165,7 @@ public class Int32ValueInternal: com.google.protobuf.kotlin.Int32Value, kotlinx. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.Int32ValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -194,6 +199,7 @@ public class UInt32ValueInternal: com.google.protobuf.kotlin.UInt32Value, kotlin kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.UInt32ValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -227,6 +233,7 @@ public class BoolValueInternal: com.google.protobuf.kotlin.BoolValue, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.BoolValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -260,6 +267,7 @@ public class StringValueInternal: com.google.protobuf.kotlin.StringValue, kotlin kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.StringValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -293,6 +301,7 @@ public class BytesValueInternal: com.google.protobuf.kotlin.BytesValue, kotlinx. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.kotlin.BytesValueInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -383,8 +392,6 @@ public fun com.google.protobuf.kotlin.DoubleValueInternal.Companion.decodeWith(m } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.DoubleValueInternal.computeSize(): Int { @@ -428,8 +435,6 @@ public fun com.google.protobuf.kotlin.FloatValueInternal.Companion.decodeWith(ms } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.FloatValueInternal.computeSize(): Int { @@ -473,8 +478,6 @@ public fun com.google.protobuf.kotlin.Int64ValueInternal.Companion.decodeWith(ms } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.Int64ValueInternal.computeSize(): Int { @@ -518,8 +521,6 @@ public fun com.google.protobuf.kotlin.UInt64ValueInternal.Companion.decodeWith(m } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.UInt64ValueInternal.computeSize(): Int { @@ -563,8 +564,6 @@ public fun com.google.protobuf.kotlin.Int32ValueInternal.Companion.decodeWith(ms } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.Int32ValueInternal.computeSize(): Int { @@ -608,8 +607,6 @@ public fun com.google.protobuf.kotlin.UInt32ValueInternal.Companion.decodeWith(m } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.UInt32ValueInternal.computeSize(): Int { @@ -653,8 +650,6 @@ public fun com.google.protobuf.kotlin.BoolValueInternal.Companion.decodeWith(msg } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.BoolValueInternal.computeSize(): Int { @@ -698,8 +693,6 @@ public fun com.google.protobuf.kotlin.StringValueInternal.Companion.decodeWith(m } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.StringValueInternal.computeSize(): Int { @@ -743,8 +736,6 @@ public fun com.google.protobuf.kotlin.BytesValueInternal.Companion.decodeWith(ms } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.kotlin.BytesValueInternal.computeSize(): Int { diff --git a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt index 88e1f950c..96c3a9fbc 100644 --- a/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt +++ b/protoc-gen/protobuf/src/main/kotlin/kotlinx/rpc/protoc/gen/ModelToProtobufKotlinCommonGenerator.kt @@ -265,6 +265,7 @@ class ModelToProtobufKotlinCommonGenerator( scope("${PB_PKG}.checkForPlatformDecodeException", nlAfterClosed = false) { code("${declaration.internalClassFullName()}.decodeWith(msg, it)") } + code("msg.checkRequiredFields()") code("return msg") } } @@ -308,8 +309,6 @@ class ModelToProtobufKotlinCommonGenerator( } } - code("msg.checkRequiredFields()") - // TODO: Make lists and maps immutable (KRPC-190) } diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt index a3c7173a7..16a272564 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf/conformance/_rpc_internal/Conformance.kt @@ -31,6 +31,7 @@ class TestStatusInternal: com.google.protobuf.conformance.TestStatus, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.TestStatusInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -64,6 +65,7 @@ class FailureSetInternal: com.google.protobuf.conformance.FailureSet, kotlinx.rp kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.FailureSetInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -106,6 +108,7 @@ class ConformanceRequestInternal: com.google.protobuf.conformance.ConformanceReq kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.ConformanceRequestInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -139,6 +142,7 @@ class ConformanceResponseInternal: com.google.protobuf.conformance.ConformanceRe kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.ConformanceResponseInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -172,6 +176,7 @@ class JspbEncodingConfigInternal: com.google.protobuf.conformance.JspbEncodingCo kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf.conformance.JspbEncodingConfigInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -254,8 +259,6 @@ fun com.google.protobuf.conformance.TestStatusInternal.Companion.decodeWith(msg: } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.conformance.TestStatusInternal.computeSize(): Int { @@ -314,8 +317,6 @@ fun com.google.protobuf.conformance.FailureSetInternal.Companion.decodeWith(msg: } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.conformance.FailureSetInternal.computeSize(): Int { @@ -434,8 +435,6 @@ fun com.google.protobuf.conformance.ConformanceRequestInternal.Companion.decodeW } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.conformance.ConformanceRequestInternal.computeSize(): Int { @@ -583,8 +582,6 @@ fun com.google.protobuf.conformance.ConformanceResponseInternal.Companion.decode } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.conformance.ConformanceResponseInternal.computeSize(): Int { @@ -664,8 +661,6 @@ fun com.google.protobuf.conformance.JspbEncodingConfigInternal.Companion.decodeW } } } - - msg.checkRequiredFields() } private fun com.google.protobuf.conformance.JspbEncodingConfigInternal.computeSize(): Int { diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt index 24e0e96e5..2ccd5e011 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/editions/proto3/_rpc_internal/TestMessagesProto3Editions.kt @@ -203,6 +203,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.editions.pro kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.NestedMessageInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -447,6 +448,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.editions.pro kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -480,6 +482,7 @@ class ForeignMessageInternal: com.google.protobuf_test_messages.editions.proto3. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.ForeignMessageInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -511,6 +514,7 @@ class NullHypothesisProto3Internal: com.google.protobuf_test_messages.editions.p kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.NullHypothesisProto3Internal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -542,6 +546,7 @@ class EnumOnlyProto3Internal: com.google.protobuf_test_messages.editions.proto3. kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.editions.proto3.EnumOnlyProto3Internal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -2583,8 +2588,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.computeSize(): Int { @@ -3346,8 +3349,6 @@ fun com.google.protobuf_test_messages.editions.proto3.ForeignMessageInternal.Com } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.ForeignMessageInternal.computeSize(): Int { @@ -3385,8 +3386,6 @@ fun com.google.protobuf_test_messages.editions.proto3.NullHypothesisProto3Intern } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.NullHypothesisProto3Internal.computeSize(): Int { @@ -3420,8 +3419,6 @@ fun com.google.protobuf_test_messages.editions.proto3.EnumOnlyProto3Internal.Com } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.EnumOnlyProto3Internal.computeSize(): Int { @@ -3476,8 +3473,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.NestedMessageInternal.computeSize(): Int { @@ -3533,8 +3528,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapInt32Int32EntryInternal.computeSize(): Int { @@ -3590,8 +3583,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapInt64Int64EntryInternal.computeSize(): Int { @@ -3647,8 +3638,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapUint32Uint32EntryInternal.computeSize(): Int { @@ -3704,8 +3693,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapUint64Uint64EntryInternal.computeSize(): Int { @@ -3761,8 +3748,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapSint32Sint32EntryInternal.computeSize(): Int { @@ -3818,8 +3803,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapSint64Sint64EntryInternal.computeSize(): Int { @@ -3875,8 +3858,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapFixed32Fixed32EntryInternal.computeSize(): Int { @@ -3932,8 +3913,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapFixed64Fixed64EntryInternal.computeSize(): Int { @@ -3989,8 +3968,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapSfixed32Sfixed32EntryInternal.computeSize(): Int { @@ -4046,8 +4023,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapSfixed64Sfixed64EntryInternal.computeSize(): Int { @@ -4103,8 +4078,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapInt32FloatEntryInternal.computeSize(): Int { @@ -4160,8 +4133,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapInt32DoubleEntryInternal.computeSize(): Int { @@ -4217,8 +4188,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapBoolBoolEntryInternal.computeSize(): Int { @@ -4274,8 +4243,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringStringEntryInternal.computeSize(): Int { @@ -4331,8 +4298,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringBytesEntryInternal.computeSize(): Int { @@ -4395,8 +4360,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringNestedMessageEntryInternal.computeSize(): Int { @@ -4459,8 +4422,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringForeignMessageEntryInternal.computeSize(): Int { @@ -4516,8 +4477,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringNestedEnumEntryInternal.computeSize(): Int { @@ -4573,8 +4532,6 @@ fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.editions.proto3.TestAllTypesProto3Internal.MapStringForeignEnumEntryInternal.computeSize(): Int { diff --git a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt index 1bdaddf9b..df9366597 100644 --- a/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt +++ b/tests/protobuf-conformance/src/main/generated-code/kotlin-multiplatform/com/google/protobuf_test_messages/proto3/_rpc_internal/TestMessagesProto3.kt @@ -203,6 +203,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.proto3.TestA kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.NestedMessageInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -447,6 +448,7 @@ class TestAllTypesProto3Internal: com.google.protobuf_test_messages.proto3.TestA kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -480,6 +482,7 @@ class ForeignMessageInternal: com.google.protobuf_test_messages.proto3.ForeignMe kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.ForeignMessageInternal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -511,6 +514,7 @@ class NullHypothesisProto3Internal: com.google.protobuf_test_messages.proto3.Nul kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.NullHypothesisProto3Internal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -542,6 +546,7 @@ class EnumOnlyProto3Internal: com.google.protobuf_test_messages.proto3.EnumOnlyP kotlinx.rpc.protobuf.internal.checkForPlatformDecodeException { com.google.protobuf_test_messages.proto3.EnumOnlyProto3Internal.decodeWith(msg, it) } + msg.checkRequiredFields() return msg } } @@ -2583,8 +2588,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.Companio } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.computeSize(): Int { @@ -3346,8 +3349,6 @@ fun com.google.protobuf_test_messages.proto3.ForeignMessageInternal.Companion.de } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.ForeignMessageInternal.computeSize(): Int { @@ -3385,8 +3386,6 @@ fun com.google.protobuf_test_messages.proto3.NullHypothesisProto3Internal.Compan } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.NullHypothesisProto3Internal.computeSize(): Int { @@ -3420,8 +3419,6 @@ fun com.google.protobuf_test_messages.proto3.EnumOnlyProto3Internal.Companion.de } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.EnumOnlyProto3Internal.computeSize(): Int { @@ -3476,8 +3473,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.NestedMe } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.NestedMessageInternal.computeSize(): Int { @@ -3533,8 +3528,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32 } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32Int32EntryInternal.computeSize(): Int { @@ -3590,8 +3583,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt64 } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt64Int64EntryInternal.computeSize(): Int { @@ -3647,8 +3638,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapUint3 } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapUint32Uint32EntryInternal.computeSize(): Int { @@ -3704,8 +3693,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapUint6 } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapUint64Uint64EntryInternal.computeSize(): Int { @@ -3761,8 +3748,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSint3 } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSint32Sint32EntryInternal.computeSize(): Int { @@ -3818,8 +3803,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSint6 } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSint64Sint64EntryInternal.computeSize(): Int { @@ -3875,8 +3858,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapFixed } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapFixed32Fixed32EntryInternal.computeSize(): Int { @@ -3932,8 +3913,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapFixed } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapFixed64Fixed64EntryInternal.computeSize(): Int { @@ -3989,8 +3968,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSfixe } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSfixed32Sfixed32EntryInternal.computeSize(): Int { @@ -4046,8 +4023,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSfixe } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapSfixed64Sfixed64EntryInternal.computeSize(): Int { @@ -4103,8 +4078,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32 } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32FloatEntryInternal.computeSize(): Int { @@ -4160,8 +4133,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32 } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapInt32DoubleEntryInternal.computeSize(): Int { @@ -4217,8 +4188,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapBoolB } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapBoolBoolEntryInternal.computeSize(): Int { @@ -4274,8 +4243,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringStringEntryInternal.computeSize(): Int { @@ -4331,8 +4298,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringBytesEntryInternal.computeSize(): Int { @@ -4395,8 +4360,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringNestedMessageEntryInternal.computeSize(): Int { @@ -4459,8 +4422,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringForeignMessageEntryInternal.computeSize(): Int { @@ -4516,8 +4477,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringNestedEnumEntryInternal.computeSize(): Int { @@ -4573,8 +4532,6 @@ fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStrin } } } - - msg.checkRequiredFields() } private fun com.google.protobuf_test_messages.proto3.TestAllTypesProto3Internal.MapStringForeignEnumEntryInternal.computeSize(): Int {