// TARGET_BACKEND: JVM_IR // WITH_STDLIB import kotlinx.serialization.* import kotlinx.serialization.json.* import kotlinx.serialization.internal.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.modules.* import java.lang.AssertionError inline fun listOfNullable(): KSerializer> = serializer>() inline fun listOfNullableWithNonNullBound(): KSerializer> = serializer>() inline fun listOfNullableNoExplicitBound(): KSerializer> = serializer>() inline fun listOfNullableWithCast(): KSerializer> = serializer>() as KSerializer> inline fun listOfUnspecifiedNullability(): KSerializer> = serializer>() inline fun getSer(module: SerializersModule): KSerializer { return module.serializer() } fun check(shouldBeNullable: Boolean, descriptor: SerialDescriptor) { if (shouldBeNullable == descriptor.isNullable) return if (shouldBeNullable) throw java.lang.AssertionError("Should be nullable, but is not: $descriptor") throw java.lang.AssertionError("Should not be nullable, but it is: $descriptor") } fun box(): String { check(false, serializer().descriptor) check(true, serializer().descriptor) check(false, serializer>().descriptor.elementDescriptors.first()) check(true, serializer>().descriptor.elementDescriptors.first()) check(true, serializer?>().descriptor) check(true, listOfNullable().descriptor.elementDescriptors.first()) check(true, listOfNullableNoExplicitBound().descriptor.elementDescriptors.first()) check(true, listOfNullableWithNonNullBound().descriptor.elementDescriptors.first()) check(true, listOfNullableWithCast().descriptor.elementDescriptors.first()) check(false, listOfUnspecifiedNullability().descriptor.elementDescriptors.first()) check(true, listOfUnspecifiedNullability().descriptor.elementDescriptors.first()) val module = EmptySerializersModule() check(false, getSer(module).descriptor) check(true, getSer(module).descriptor) return "OK" }