@@ -9,12 +9,13 @@ import com.badoo.reaktive.observable.zip
9
9
import com.badoo.reaktive.single.asObservable
10
10
import com.badoo.reaktive.single.map
11
11
import kotlinx.serialization.ExperimentalSerializationApi
12
+ import kotlinx.serialization.InternalSerializationApi
12
13
import kotlinx.serialization.KSerializer
13
14
import kotlinx.serialization.SerialName
14
15
import kotlinx.serialization.Serializable
15
16
import kotlinx.serialization.descriptors.SerialDescriptor
16
- import kotlinx.serialization.descriptors.SerialKind
17
17
import kotlinx.serialization.descriptors.StructureKind
18
+ import kotlinx.serialization.descriptors.buildSerialDescriptor
18
19
import kotlinx.serialization.encoding.CompositeDecoder
19
20
import kotlinx.serialization.encoding.Decoder
20
21
import kotlinx.serialization.encoding.Encoder
@@ -206,7 +207,13 @@ class ZipOutputSerializer<CommonT, Out : IZipOutput<CommonT>>(
206
207
override val descriptor: SerialDescriptor = if (elementSerializers.size == 1 ) {
207
208
elementSerializers.single().descriptor
208
209
} else {
209
- ZipNOutputDesc (elementSerializers.map { it.descriptor }.toTypedArray())
210
+ val typeParameters = elementSerializers.map { it.descriptor }.toTypedArray()
211
+ @OptIn(InternalSerializationApi ::class )
212
+ buildSerialDescriptor(" modelix.zipN" , StructureKind .LIST , * typeParameters) {
213
+ elementSerializers.forEachIndexed { index, elementSerializer ->
214
+ element(index.toString(), elementSerializer.descriptor)
215
+ }
216
+ }
210
217
}
211
218
212
219
override fun serialize (encoder : Encoder , value : ZipStepOutput <Out , CommonT >) {
@@ -222,39 +229,6 @@ class ZipOutputSerializer<CommonT, Out : IZipOutput<CommonT>>(
222
229
}
223
230
}
224
231
225
- internal class ZipNOutputDesc (val elementDesc : Array <SerialDescriptor >) : SerialDescriptor {
226
- @ExperimentalSerializationApi
227
- override val elementsCount: Int
228
- get() = elementDesc.size
229
-
230
- @ExperimentalSerializationApi
231
- override val kind: SerialKind
232
- get() = StructureKind .LIST
233
-
234
- @ExperimentalSerializationApi
235
- override val serialName: String
236
- get() = " modelix.zipN"
237
-
238
- @ExperimentalSerializationApi
239
- override fun getElementAnnotations (index : Int ): List <Annotation > = emptyList()
240
-
241
- @ExperimentalSerializationApi
242
- override fun getElementDescriptor (index : Int ): SerialDescriptor = elementDesc[index]
243
-
244
- @ExperimentalSerializationApi
245
- override fun getElementIndex (name : String ): Int {
246
- return name.toIntOrNull() ? : throw IllegalArgumentException (" $name is not a valid list index" )
247
- }
248
-
249
- @ExperimentalSerializationApi
250
- override fun getElementName (index : Int ): String {
251
- return index.toString()
252
- }
253
-
254
- @ExperimentalSerializationApi
255
- override fun isElementOptional (index : Int ): Boolean = false
256
- }
257
-
258
232
data class ZipStepOutput <E : IZipOutput <Common >, Common >(val values : List <IStepOutput <Common >>) : IStepOutput<E> {
259
233
override val value: E
260
234
get() = ZipNOutput (values.map { it.value }) as E
0 commit comments