@@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.deser.std.StdValueInstantiator
12
12
import com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException
13
13
import com.fasterxml.jackson.module.kotlin.ReflectionCache
14
14
import com.fasterxml.jackson.module.kotlin.deser.value_instantiator.creator.ValueCreator
15
+ import com.fasterxml.jackson.module.kotlin.deser.value_instantiator.creator.ValueParameter
15
16
import com.fasterxml.jackson.module.kotlin.isKotlinClass
16
17
import com.fasterxml.jackson.module.kotlin.wrapWithPath
17
18
import kotlin.reflect.KParameter
@@ -25,6 +26,10 @@ internal class KotlinValueInstantiator(
25
26
private val nullIsSameAsDefault : Boolean ,
26
27
private val strictNullChecks : Boolean
27
28
) : StdValueInstantiator(src) {
29
+ // If the collection type argument cannot be obtained, treat it as nullable
30
+ // @see com.fasterxml.jackson.module.kotlin._ported.test.StrictNullChecksTest#testListOfGenericWithNullValue
31
+ private fun ValueParameter.isNullishTypeAt (index : Int ) = arguments.getOrNull(index)?.isNullable ? : true
32
+
28
33
override fun createFromObjectWith (
29
34
ctxt : DeserializationContext ,
30
35
props : Array <out SettableBeanProperty >,
@@ -76,11 +81,11 @@ internal class KotlinValueInstantiator(
76
81
// If an error occurs, Argument.name is always non-null
77
82
// @see com.fasterxml.jackson.module.kotlin.deser.value_instantiator.creator.Argument
78
83
when {
79
- paramVal is Collection <* > && ! paramDef.arguments[ 0 ].isNullable && paramVal.any { it == null } ->
84
+ paramVal is Collection <* > && ! paramDef.isNullishTypeAt( 0 ) && paramVal.any { it == null } ->
80
85
" collection" to paramDef.arguments[0 ].name!!
81
- paramVal is Array <* > && ! paramDef.arguments[ 0 ].isNullable && paramVal.any { it == null } ->
86
+ paramVal is Array <* > && ! paramDef.isNullishTypeAt( 0 ) && paramVal.any { it == null } ->
82
87
" array" to paramDef.arguments[0 ].name!!
83
- paramVal is Map <* , * > && ! paramDef.arguments[ 1 ].isNullable && paramVal.values.any { it == null } ->
88
+ paramVal is Map <* , * > && ! paramDef.isNullishTypeAt( 1 ) && paramVal.values.any { it == null } ->
84
89
" map" to paramDef.arguments[1 ].name!!
85
90
else -> null
86
91
}?.let { (paramType, itemType) ->
0 commit comments