File tree Expand file tree Collapse file tree
bson-kotlin/src/main/kotlin/org/bson/codecs/kotlin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,9 @@ internal data class DataClassCodec<T : Any>(
105105 // Optional parameters (with defaults) are left absent so callBy uses the default value.
106106 fieldNamePropertyModelMap.values.forEach {
107107 if (it.param !in args && ! it.param.isOptional) {
108+ // Only error for concrete types (KClass). Generic type parameters (KTypeParameter)
109+ // may be nullable at runtime even though isMarkedNullable is false at the
110+ // declaration site (e.g. Box<T>(val boxed: T) instantiated as Box<String?>).
108111 if (! it.param.type.isMarkedNullable && it.param.type.classifier is KClass <* >) {
109112 throw CodecConfigurationException (
110113 " Required field '${it.fieldName} ' is missing from the document for ${kClass.simpleName} data class" )
You can’t perform that action at this time.
0 commit comments