Более корректный код определения примитивов
This commit is contained in:
parent
ec98c6970c
commit
b9b4140832
@ -238,15 +238,15 @@ class KConcreteTypeAdapter<T : Any> private constructor(
|
||||
val type = param.parameterizedType as? Class<*> ?: continue
|
||||
|
||||
if (type.isPrimitive) {
|
||||
syntheticPrimitives[i] = when (type.name) {
|
||||
"boolean" -> false
|
||||
"int" -> 0
|
||||
"long" -> 0L
|
||||
"short" -> (0).toShort()
|
||||
"byte" -> (0).toByte()
|
||||
"char" -> (0).toChar()
|
||||
"float" -> 0f
|
||||
"double" -> 0.0
|
||||
syntheticPrimitives[i] = when (type) {
|
||||
java.lang.Boolean.TYPE -> false
|
||||
java.lang.Integer.TYPE -> 0
|
||||
java.lang.Long.TYPE -> 0L
|
||||
java.lang.Short.TYPE -> (0).toShort()
|
||||
java.lang.Byte.TYPE -> (0).toByte()
|
||||
java.lang.Character.TYPE -> (0).toChar()
|
||||
java.lang.Float.TYPE -> 0f
|
||||
java.lang.Double.TYPE -> 0.0
|
||||
else -> throw IllegalArgumentException("mamma mia: ${type.name}")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user