[K2] Properly serialize constant values

#KT-56190 Fixed
This commit is contained in:
Ivan Kylchik
2023-03-31 23:36:16 +02:00
committed by Space Team
parent ac480e2285
commit 8499891756
14 changed files with 135 additions and 44 deletions
@@ -153,7 +153,11 @@ internal class DefaultCallInterceptor(override val interpreter: IrInterpreter) :
val receiverType = irFunction.dispatchReceiverParameter?.type ?: irFunction.extensionReceiverParameter?.type
val argsType = (listOfNotNull(receiverType) + irFunction.valueParameters.map { it.type }).map {
// TODO: for consistency with current K/JS implementation Float constant should be treated as a Double (KT-35422)
if (environment.configuration.treatFloatInSpecialWay && it.isFloat()) irBuiltIns.doubleType else it
if (environment.configuration.treatFloatInSpecialWay && it.makeNotNull().isFloat()) {
if (it.isNullable()) irBuiltIns.doubleType.makeNullable() else irBuiltIns.doubleType
} else {
it
}
}
val argsValues = args.wrap(this, irFunction)
@@ -52,7 +52,7 @@ enum class EvaluationMode(protected val mustCheckBody: Boolean) {
private val forbiddenMethodsOnStrings = setOf("subSequence", "hashCode", "<init>")
private val allowedExtensionFunctions = setOf(
"kotlin.floorDiv", "kotlin.mod", "kotlin.NumbersKt.floorDiv", "kotlin.NumbersKt.mod", "kotlin.<get-code>",
"kotlin.internal.ir.EQEQ",
"kotlin.internal.ir.EQEQ", "kotlin.internal.ir.ieee754equals",
)
override fun canEvaluateFunction(function: IrFunction, context: IrCall?): Boolean {