Skip to content

Commit 6840228

Browse files
committed
Replace with kotlinx.metadata
1 parent 631dcdf commit 6840228

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinAnnotationIntrospector.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import com.fasterxml.jackson.module.kotlin.ser.serializers.ValueClassStaticJsonV
1818
import kotlinx.metadata.Flag
1919
import kotlinx.metadata.KmClassifier
2020
import kotlinx.metadata.KmProperty
21+
import kotlinx.metadata.jvm.fieldSignature
2122
import kotlinx.metadata.jvm.getterSignature
2223
import kotlinx.metadata.jvm.setterSignature
2324
import java.lang.reflect.AccessibleObject
@@ -29,7 +30,6 @@ import kotlin.reflect.KType
2930
import kotlin.reflect.full.createType
3031
import kotlin.reflect.jvm.javaType
3132
import kotlin.reflect.jvm.kotlinFunction
32-
import kotlin.reflect.jvm.kotlinProperty
3333

3434
internal class KotlinAnnotationIntrospector(
3535
private val context: Module.SetupContext,
@@ -124,8 +124,14 @@ internal class KotlinAnnotationIntrospector(
124124
}
125125

126126
private fun AnnotatedField.hasRequiredMarker(): Boolean? {
127-
val byAnnotation = (member as Field).isRequiredByAnnotation()
128-
val byNullability = (member as Field).kotlinProperty?.returnType?.isRequired()
127+
val member = member as Field
128+
129+
val byAnnotation = member.isRequiredByAnnotation()
130+
val fieldSignature = member.toSignature()
131+
val byNullability = member.declaringClass.toKmClass()
132+
?.properties
133+
?.find { it.fieldSignature == fieldSignature }
134+
?.let { !Flag.Type.IS_NULLABLE(it.returnType.flags) }
129135

130136
return requiredAnnotationOrNullability(byAnnotation, byNullability)
131137
}
@@ -220,10 +226,3 @@ internal class KotlinAnnotationIntrospector(
220226
val UNIT_TYPE: KType = Unit::class.createType()
221227
}
222228
}
223-
224-
@JvmInline
225-
private value class VC(val v: Int)
226-
227-
internal fun main() {
228-
val vc = VC::class.java.toKmClass()
229-
}

0 commit comments

Comments
 (0)