diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt index 2b6155a6..22ca799f 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt @@ -4,7 +4,13 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.PropertyName import com.fasterxml.jackson.databind.cfg.MapperConfig -import com.fasterxml.jackson.databind.introspect.* +import com.fasterxml.jackson.databind.introspect.Annotated +import com.fasterxml.jackson.databind.introspect.AnnotatedConstructor +import com.fasterxml.jackson.databind.introspect.AnnotatedField +import com.fasterxml.jackson.databind.introspect.AnnotatedMember +import com.fasterxml.jackson.databind.introspect.AnnotatedMethod +import com.fasterxml.jackson.databind.introspect.AnnotatedParameter +import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector import com.fasterxml.jackson.databind.util.BeanUtil import java.lang.reflect.Constructor import java.lang.reflect.Method @@ -32,6 +38,10 @@ internal class KotlinNamesAnnotationIntrospector(val module: KotlinModule, val c member.parameterCount == 0) { return member.name.substringAfter("is").decapitalize().substringBefore('-') } + } else if (member is AnnotatedMethod && member.declaringClass.isKotlinClass()) { + if (cache.isKotlinGeneratedMethod(member) { it.declaringClass.declaredFields.any { f -> f.name == member.name } }) { + return member.name + } } else if (member is AnnotatedParameter) { return findKotlinParameterName(member) } diff --git a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/GitHub337.kt b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/GitHub337.kt index 9461bb53..d1d5840e 100644 --- a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/GitHub337.kt +++ b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/GitHub337.kt @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.MapperFeature.SORT_PROPERTIES_ALPHABETICALLY import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import org.junit.Ignore import org.junit.Test import kotlin.test.assertEquals @@ -18,7 +17,6 @@ class TestGitHub337 { private val writer = mapper.writerWithDefaultPrettyPrinter() @Test - @Ignore fun test_ClassWithIsFields() { data class ClassWithIsFields( val isBooleanField: Boolean, @@ -35,7 +33,6 @@ class TestGitHub337 { } @Test - @Ignore fun test_AnnotatedClassWithIsFields() { data class ClassWithIsFields( @JsonProperty("isBooleanField") val isBooleanField: Boolean,