Fix findSubtypes returning wrong values in super edge cases.
It's simpler to look at sealedSubclasses directly than to determine isSealed, so I fixed it while I was at it.
MODIFY
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinAnnotationIntrospector.kt
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinAnnotationIntrospector.kt
@@ -63,20 +63,13 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
* Subclasses can be detected automatically for sealed classes, since all possible subclasses are known
* at compile-time to Kotlin. This makes [com.fasterxml.jackson.annotation.JsonSubTypes] redundant.
*/
- override fun findSubtypes(a: Annotated): MutableList<NamedType>? {
-
- val rawType = a.rawType
- if (rawType.isKotlinClass()) {
- val kClass = rawType.kotlin
- if (kClass.isSealed) {
- return kClass.sealedSubclasses
+ override fun findSubtypes(a: Annotated): MutableList<NamedType>? = a.rawType
+ .takeIf { it.isKotlinClass() }
+ ?.let { rawType ->
+ rawType.kotlin.sealedSubclasses
.map { NamedType(it.java) }
.toMutableList()
- }
- }
-
- return null
-
+ .ifEmpty { null }
}
private fun AnnotatedField.hasRequiredMarker(): Boolean? {

Fix findSubtypes returning wrong values in super edge cases.

It's simpler to look at sealedSubclasses directly than to determine isSealed, so I fixed it while I was at it.