If you run the null validation in containsIllegalNullValues on a nullable list, e.g.:
val nullableListWithNull = listOf<String?>(null)
then it will return false, because on iterating through the list, element is null. This may seem like an odd scenario but we experience it when using Gson with a custom deserialiser that ignores certain elements, for which it returns null.
I did look at whether it was possible to improve on this, e.g. examine the return type of the collection's iterator to see if isMarkedNullable would be true, but I couldn't find a working solution. I think this a product of how Kotlin does generics, e.g. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-type/is-marked-nullable.html
If you run the null validation in
containsIllegalNullValueson a nullable list, e.g.:val nullableListWithNull = listOf<String?>(null)then it will return false, because on iterating through the list,
elementis null. This may seem like an odd scenario but we experience it when using Gson with a custom deserialiser that ignores certain elements, for which it returns null.I did look at whether it was possible to improve on this, e.g. examine the return type of the collection's iterator to see if
isMarkedNullablewould be true, but I couldn't find a working solution. I think this a product of how Kotlin does generics, e.g. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-type/is-marked-nullable.html