Analysis API: fix unsigned constant value creation for fe1.0

This commit is contained in:
Ilya Kirillov
2021-11-24 13:12:27 +01:00
parent 7919dae558
commit c4e5ec2ff2
@@ -272,10 +272,21 @@ internal val MemberDescriptor.ktModality: Modality
internal fun ConstantValue<*>.toKtConstantValue(): KtConstantValue {
return when (this) {
is ErrorValue.ErrorValueWithMessage -> KtConstantValue.KtErrorConstantValue(message, sourcePsi = null)
else -> {
KtConstantValueFactory.createConstantValue(value)
?: error("Unexpected constant value $value")
}
is BooleanValue -> KtConstantValue.KtBooleanConstantValue(value, sourcePsi = null)
is DoubleValue -> KtConstantValue.KtDoubleConstantValue(value, sourcePsi = null)
is FloatValue -> KtConstantValue.KtFloatConstantValue(value, sourcePsi = null)
is NullValue -> KtConstantValue.KtNullConstantValue(sourcePsi = null)
is StringValue -> KtConstantValue.KtStringConstantValue(value, sourcePsi = null)
is ByteValue -> KtConstantValue.KtByteConstantValue(value, sourcePsi = null)
is CharValue -> KtConstantValue.KtCharConstantValue(value, sourcePsi = null)
is IntValue -> KtConstantValue.KtIntConstantValue(value, sourcePsi = null)
is LongValue -> KtConstantValue.KtLongConstantValue(value, sourcePsi = null)
is ShortValue -> KtConstantValue.KtShortConstantValue(value, sourcePsi = null)
is UByteValue -> KtConstantValue.KtUnsignedByteConstantValue(value.toUByte(), sourcePsi = null)
is UIntValue -> KtConstantValue.KtUnsignedIntConstantValue(value.toUInt(), sourcePsi = null)
is ULongValue -> KtConstantValue.KtUnsignedLongConstantValue(value.toULong(), sourcePsi = null)
is UShortValue -> KtConstantValue.KtUnsignedShortConstantValue(value.toUShort(), sourcePsi = null)
else -> error("Unexpected constant value $value")
}
}