Более корректный код определения примитивов

This commit is contained in:
DBotThePony 2022-12-30 11:44:11 +07:00
parent ec98c6970c
commit b9b4140832
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -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}")
}
}