mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 08:29:22 +08:00
Fix nullable properties of TypeVariable types
We were forgetting to apply the property's nullability to the resolved type. Fixes #521
This commit is contained in:
@@ -33,7 +33,7 @@ internal data class DelegateKey(
|
||||
private val type: TypeName,
|
||||
private val jsonQualifiers: Set<AnnotationMirror>
|
||||
) {
|
||||
val nullable get() = type.nullable || type is TypeVariableName
|
||||
val nullable get() = type.nullable
|
||||
|
||||
/** Returns an adapter to use when encoding and decoding this property. */
|
||||
fun generateProperty(
|
||||
|
@@ -80,6 +80,7 @@ internal fun Type.asTypeName(
|
||||
val realType = when {
|
||||
hasTypeParameter() -> return getTypeParameter(typeParameter)
|
||||
.asTypeName(nameResolver, getTypeParameter, resolveAliases)
|
||||
.let { if (nullable) it.asNullable() else it }
|
||||
hasTypeParameterName() -> typeParameterName
|
||||
hasAbbreviatedType() && !resolveAliases -> abbreviatedType.typeAliasName
|
||||
else -> className
|
||||
|
Reference in New Issue
Block a user