Skip to content

Commit

Permalink
Deprecate .isNullable in SerialDescriptor builder (#2040)
Browse files Browse the repository at this point in the history
because it wasn't working properly and better alternative exists.

Fixes #1929
  • Loading branch information
sandwwraith committed Sep 22, 2022
1 parent ec83042 commit 4ed6cce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Expand Up @@ -240,6 +240,7 @@ public class ClassSerialDescriptorBuilder internal constructor(
* in its [KSerializer] type parameter and handle nulls during encoding and decoding.
*/
@ExperimentalSerializationApi
@Deprecated("isNullable inside buildSerialDescriptor is deprecated. Please use SerialDescriptor.nullable extension on a builder result.", level = DeprecationLevel.ERROR)
public var isNullable: Boolean = false

/**
Expand Down
Expand Up @@ -87,4 +87,11 @@ class SerialDescriptorBuilderTest {
assertFailsWith<IllegalArgumentException> { PrimitiveSerialDescriptor(" ", PrimitiveKind.STRING) }
assertFailsWith<IllegalArgumentException> { PrimitiveSerialDescriptor("\t", PrimitiveKind.STRING) }
}

@Test
fun testNullableBuild() {
val descriptor = buildClassSerialDescriptor("my.Simple") {}.nullable
assertTrue(descriptor.isNullable)
assertEquals("my.Simple?", descriptor.serialName)
}
}

0 comments on commit 4ed6cce

Please sign in to comment.