JVM IR: fix operand type for CompareTo intrinsic

It's incorrect to take the first parameter type from the expression
itself because it can be nullable if smart casts are used. And if it's
nullable, it's mapped to the wrapper type and calling
`comparisonOperandType` for it makes no sense. Instead, take the type
from the callee function, as it's guaranteed to be mapped to a JVM
primitive type.

E.g. in `test1` function in the added test, the problem was that the
dispatch receiver type of the call expression is `Double?`, which is
mapped to `java/lang/Double`, whereas we clearly wanted to obtain the
primitive `D` (double) type.

 #KT-52163 Fixed
This commit is contained in:
Alexander Udalov
2022-04-28 23:01:59 +02:00
parent f8ef028da3
commit 6d664bcd10
14 changed files with 151 additions and 12 deletions
@@ -21170,6 +21170,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/intrinsics/kt12125_inc_2.kt");
}
@TestMetadata("kt52163_boolean.kt")
public void testKt52163_boolean() throws Exception {
runTest("compiler/testData/codegen/box/intrinsics/kt52163_boolean.kt");
}
@TestMetadata("kt52163_doubleCompareToInt.kt")
public void testKt52163_doubleCompareToInt() throws Exception {
runTest("compiler/testData/codegen/box/intrinsics/kt52163_doubleCompareToInt.kt");
}
@TestMetadata("kt5937.kt")
public void testKt5937() throws Exception {
runTest("compiler/testData/codegen/box/intrinsics/kt5937.kt");