Skip to content

Commit d454181

Browse files
committed
optimize for nullability
1 parent 9338295 commit d454181

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
9999
// This could be a setter or a getter of a class property or
100100
// a setter-like/getter-like method.
101101
private fun AnnotatedMethod.hasRequiredMarker(): Boolean? = this.getRequiredMarkerFromCorrespondingAccessor()
102-
?: this.member.kotlinFunction?.getRequiredMarkerFromAccessorLikeMethod()
102+
?: this.member.getRequiredMarkerFromAccessorLikeMethod()
103103

104104
private fun AnnotatedMethod.getRequiredMarkerFromCorrespondingAccessor(): Boolean? {
105105
member.declaringClass.kotlin.declaredMemberProperties.forEach { kProperty1 ->
@@ -121,11 +121,11 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
121121
}
122122

123123
// Is the member method a regular method of the data class or
124-
private fun KFunction<*>.getRequiredMarkerFromAccessorLikeMethod(): Boolean? {
125-
val byAnnotation = this.javaMethod?.isRequiredByAnnotation()
124+
private fun Method.getRequiredMarkerFromAccessorLikeMethod(): Boolean? = this.kotlinFunction?.let { method ->
125+
val byAnnotation = this.isRequiredByAnnotation()
126126
return when {
127-
this.isGetterLike() -> requiredAnnotationOrNullability(byAnnotation, this.returnType.isRequired())
128-
this.isSetterLike() -> requiredAnnotationOrNullability(byAnnotation, this.isMethodParameterRequired(0))
127+
method.isGetterLike() -> requiredAnnotationOrNullability(byAnnotation, method.returnType.isRequired())
128+
method.isSetterLike() -> requiredAnnotationOrNullability(byAnnotation, method.isMethodParameterRequired(0))
129129
else -> null
130130
}
131131
}

0 commit comments

Comments
 (0)