Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of @ExperimentalUnsignedTypes on our declarations that levera… #1962

Merged
merged 4 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ buildscript {
ext.experimentalsInTestEnabled = ["-progressive", "-opt-in=kotlin.Experimental",
"-opt-in=kotlin.ExperimentalMultiplatform",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=kotlinx.serialization.InternalSerializationApi",
"-opt-in=kotlin.ExperimentalUnsignedTypes"
"-opt-in=kotlinx.serialization.InternalSerializationApi"
]
ext.koverEnabled = property('kover.enabled') ?: true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,21 @@ public fun <K, V> MapSerializer(
/**
* Returns serializer for [UInt].
*/
@ExperimentalUnsignedTypes
public fun UInt.Companion.serializer(): KSerializer<UInt> = UIntSerializer

/**
* Returns serializer for [ULong].
*/
@ExperimentalUnsignedTypes
public fun ULong.Companion.serializer(): KSerializer<ULong> = ULongSerializer

/**
* Returns serializer for [UByte].
*/
@ExperimentalUnsignedTypes
public fun UByte.Companion.serializer(): KSerializer<UByte> = UByteSerializer

/**
* Returns serializer for [UShort].
*/
@ExperimentalUnsignedTypes
public fun UShort.Companion.serializer(): KSerializer<UShort> = UShortSerializer

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*

@PublishedApi
@ExperimentalUnsignedTypes
internal object UIntSerializer : KSerializer<UInt> {
override val descriptor: SerialDescriptor = InlinePrimitiveDescriptor("kotlin.UInt", Int.serializer())

Expand All @@ -24,7 +23,6 @@ internal object UIntSerializer : KSerializer<UInt> {
}

@PublishedApi
@ExperimentalUnsignedTypes
internal object ULongSerializer : KSerializer<ULong> {
override val descriptor: SerialDescriptor = InlinePrimitiveDescriptor("kotlin.ULong", Long.serializer())

Expand All @@ -38,7 +36,6 @@ internal object ULongSerializer : KSerializer<ULong> {
}

@PublishedApi
@ExperimentalUnsignedTypes
internal object UByteSerializer : KSerializer<UByte> {
override val descriptor: SerialDescriptor = InlinePrimitiveDescriptor("kotlin.UByte", Byte.serializer())

Expand All @@ -52,7 +49,6 @@ internal object UByteSerializer : KSerializer<UByte> {
}

@PublishedApi
@ExperimentalUnsignedTypes
internal object UShortSerializer : KSerializer<UShort> {
override val descriptor: SerialDescriptor = InlinePrimitiveDescriptor("kotlin.UShort", Short.serializer())

Expand Down
2 changes: 0 additions & 2 deletions docs/builtin-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ Their natural representation in JSON is used.

<!--- TEST -->

> Experimental unsigned numbers as well as other experimental inline classes are not supported by Kotlin Serialization yet.


### Long numbers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private object JsonLiteralSerializer : KSerializer<JsonLiteral> {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("kotlinx.serialization.json.JsonLiteral", PrimitiveKind.STRING)

@OptIn(ExperimentalUnsignedTypes::class, ExperimentalSerializationApi::class)
@OptIn(ExperimentalSerializationApi::class)
override fun serialize(encoder: Encoder, value: JsonLiteral) {
verify(encoder)
if (value.isString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ internal open class Composer(@JvmField internal val sb: JsonStringBuilder) {
fun printQuoted(value: String): Unit = sb.appendQuoted(value)
}

@ExperimentalUnsignedTypes
internal class ComposerForUnsignedNumbers(sb: JsonStringBuilder, private val forceQuoting: Boolean) : Composer(sb) {
override fun print(v: Int) {
if (forceQuoting) printQuoted(v.toUInt().toString()) else print(v.toUInt().toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import kotlin.jvm.*
/**
* [JsonDecoder] which reads given JSON from [AbstractJsonLexer] field by field.
*/
@OptIn(ExperimentalSerializationApi::class, ExperimentalUnsignedTypes::class)
@OptIn(ExperimentalSerializationApi::class)
qwwdfsad marked this conversation as resolved.
Show resolved Hide resolved
internal open class StreamingJsonDecoder(
final override val json: Json,
private val mode: WriteMode,
Expand Down Expand Up @@ -354,7 +354,6 @@ internal open class StreamingJsonDecoder(
}

@OptIn(ExperimentalSerializationApi::class)
@ExperimentalUnsignedTypes
internal class JsonDecoderForUnsignedTypes(
private val lexer: AbstractJsonLexer,
json: Json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import kotlinx.serialization.json.*
import kotlinx.serialization.modules.*
import kotlin.native.concurrent.*

@OptIn(ExperimentalUnsignedTypes::class)
@SharedImmutable
private val unsignedNumberDescriptors = setOf(
UInt.serializer().descriptor,
Expand All @@ -24,7 +23,7 @@ private val unsignedNumberDescriptors = setOf(
internal val SerialDescriptor.isUnsignedNumber: Boolean
get() = this.isInline && this in unsignedNumberDescriptors

@OptIn(ExperimentalSerializationApi::class, ExperimentalUnsignedTypes::class)
@OptIn(ExperimentalSerializationApi::class)
internal class StreamingJsonEncoder(
private val composer: Composer,
override val json: Json,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ private sealed class AbstractJsonTreeDecoder(
return this as? JsonLiteral ?: throw JsonDecodingException(-1, "Unexpected 'null' when $type was expected")
}

@OptIn(ExperimentalUnsignedTypes::class)
override fun decodeTaggedInline(tag: String, inlineDescriptor: SerialDescriptor): Decoder =
if (inlineDescriptor.isUnsignedNumber) JsonDecoderForUnsignedTypes(StringJsonLexer(getPrimitiveValue(tag).content), json)
else super.decodeTaggedInline(tag, inlineDescriptor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ private sealed class AbstractJsonTreeEncoder(
putElement(tag, JsonPrimitive(value.toString()))
}

@OptIn(ExperimentalUnsignedTypes::class)
override fun encodeTaggedInline(tag: String, inlineDescriptor: SerialDescriptor): Encoder =
if (inlineDescriptor.isUnsignedNumber) object : AbstractEncoder() {
override val serializersModule: SerializersModule = json.serializersModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:OptIn(ExperimentalUnsignedTypes::class)

package kotlinx.serialization.features.inline

import kotlinx.serialization.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
*/

@file:Suppress("INLINE_CLASSES_NOT_SUPPORTED", "SERIALIZER_NOT_FOUND")
@file:OptIn(ExperimentalUnsignedTypes::class)

/*
* Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package kotlinx.serialization.features.inline

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@file:Suppress("INLINE_CLASSES_NOT_SUPPORTED", "SERIALIZER_NOT_FOUND")
@file:OptIn(ExperimentalUnsignedTypes::class)
/*
* Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package kotlinx.serialization.features.inline
Expand Down