@@ -18,6 +18,7 @@ import com.fasterxml.jackson.module.kotlin.ser.serializers.ValueClassStaticJsonV
18
18
import kotlinx.metadata.Flag
19
19
import kotlinx.metadata.KmClassifier
20
20
import kotlinx.metadata.KmProperty
21
+ import kotlinx.metadata.jvm.fieldSignature
21
22
import kotlinx.metadata.jvm.getterSignature
22
23
import kotlinx.metadata.jvm.setterSignature
23
24
import java.lang.reflect.AccessibleObject
@@ -29,7 +30,6 @@ import kotlin.reflect.KType
29
30
import kotlin.reflect.full.createType
30
31
import kotlin.reflect.jvm.javaType
31
32
import kotlin.reflect.jvm.kotlinFunction
32
- import kotlin.reflect.jvm.kotlinProperty
33
33
34
34
internal class KotlinAnnotationIntrospector (
35
35
private val context : Module .SetupContext ,
@@ -124,8 +124,14 @@ internal class KotlinAnnotationIntrospector(
124
124
}
125
125
126
126
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) }
129
135
130
136
return requiredAnnotationOrNullability(byAnnotation, byNullability)
131
137
}
@@ -220,10 +226,3 @@ internal class KotlinAnnotationIntrospector(
220
226
val UNIT_TYPE : KType = Unit ::class .createType()
221
227
}
222
228
}
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