Skip to content

Commit

Permalink
fix Omissible<T>#isOmitted and Omissible<T>#isPresent not working for…
Browse files Browse the repository at this point in the history
… nullable types
  • Loading branch information
topi314 committed Dec 3, 2023
1 parent acc6069 commit 6edb769
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ class OmissableSerializer<T>(private val childSerializer: KSerializer<T>) : KSer
}

@OptIn(ExperimentalContracts::class)
fun <T : Any> Omissible<T>.isPresent(): Boolean {
fun <T : Any?> Omissible<T>.isPresent(): Boolean {
contract {
returns(true) implies (this@isPresent is Omissible.Present<T>)
}
return this is Omissible.Present
}

@OptIn(ExperimentalContracts::class)
fun <T : Any> Omissible<T>.isOmitted(): Boolean {
fun <T : Any?> Omissible<T>.isOmitted(): Boolean {
contract {
returns(true) implies (this@isOmitted is Omissible.Omitted<T>)
}
Expand Down

0 comments on commit 6edb769

Please sign in to comment.