mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Fix variance issues
This commit is contained in:
@@ -99,7 +99,7 @@ abstract class TypeRenderer {
|
||||
else -> throw IllegalArgumentException(
|
||||
"Unrepresentable wildcard type. Cannot have more than one bound: $typeName")
|
||||
}
|
||||
CodeBlock.of("%T.%L(%T::class.java)", Types::class, method, target)
|
||||
CodeBlock.of("%T.%L(%T::class.java)", Types::class, method, target.asNonNull())
|
||||
}
|
||||
|
||||
is TypeVariableName -> renderTypeVariable(typeName)
|
||||
|
@@ -108,15 +108,7 @@ internal fun Type.asTypeName(
|
||||
nullableProjection?.let { projection ->
|
||||
when (projection) {
|
||||
Type.Argument.Projection.IN -> WildcardTypeName.supertypeOf(argumentTypeName)
|
||||
Type.Argument.Projection.OUT -> {
|
||||
if (argumentTypeName == ANY) {
|
||||
// This becomes a *, which we actually don't want here.
|
||||
// List<Any> works with List<*>, but List<*> doesn't work with List<Any>
|
||||
argumentTypeName
|
||||
} else {
|
||||
WildcardTypeName.subtypeOf(argumentTypeName)
|
||||
}
|
||||
}
|
||||
Type.Argument.Projection.OUT -> WildcardTypeName.subtypeOf(argumentTypeName)
|
||||
Type.Argument.Projection.STAR -> WildcardTypeName.STAR
|
||||
Type.Argument.Projection.INV -> TODO("INV projection is unsupported")
|
||||
}
|
||||
|
Reference in New Issue
Block a user