fix: correct finalValue assignment logic in PropertyType for autoConversion

This commit is contained in:
2025-11-14 17:22:01 +08:00
parent 23c7283286
commit bb56b66e86

View File

@@ -145,8 +145,10 @@ internal fun Any.createTypeValueByType(autoConversion: Boolean, key: String): Pr
.replace("\"", "\\\"") .replace("\"", "\\\"")
val trimmed = valueString.trim() val trimmed = valueString.trim()
if (!autoConversion) return PropertyTypeValue(this.toString(), "\"$valueString\"", String::class)
val finalValue = if (autoConversion) when (typeSpec) { val finalValue = when (typeSpec) {
String::class, CharSequence::class -> "\"$trimmed\"" String::class, CharSequence::class -> "\"$trimmed\""
Char::class -> "'$trimmed'" Char::class -> "'$trimmed'"
Boolean::class -> trimmed Boolean::class -> trimmed
@@ -157,7 +159,7 @@ internal fun Any.createTypeValueByType(autoConversion: Boolean, key: String): Pr
"Unsupported property \"$key\" value type: ${typeSpec.qualifiedName}, " + "Unsupported property \"$key\" value type: ${typeSpec.qualifiedName}, " +
"only String, CharSequence, Char, Boolean, Int, Long, Float, Double are supported." "only String, CharSequence, Char, Boolean, Int, Long, Float, Double are supported."
) )
} else "\"$valueString\"" }
return PropertyTypeValue(this.toString(), finalValue, typeSpec) return PropertyTypeValue(this.toString(), finalValue, typeSpec)
} }