JVM: Fix IEEE 754 comparison generation for boxed numbers
This commit is contained in:
@@ -4044,7 +4044,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
boolean properIeee754Comparisons = shouldUseProperIeee754Comparisons();
|
boolean properIeee754Comparisons = shouldUseProperIeee754Comparisons();
|
||||||
|
|
||||||
if (properIeee754Comparisons && left754Type != null && right754Type != null) {
|
if (properIeee754Comparisons && left754Type != null && right754Type != null) {
|
||||||
type = comparisonOperandType(leftType, rightType);
|
type = comparisonOperandType(left754Type.type, right754Type.type);
|
||||||
|
//type = comparisonOperandType(leftType, rightType);
|
||||||
leftValue = gen(left);
|
leftValue = gen(left);
|
||||||
rightValue = gen(right);
|
rightValue = gen(right);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// reason - multifile tests are not supported in JS tests
|
||||||
|
//FILE: Holder.java
|
||||||
|
import org.jetbrains.annotations.*;
|
||||||
|
|
||||||
|
class Holder {
|
||||||
|
public @NotNull Double value;
|
||||||
|
public Holder(Double value) { this.value = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: test.kt
|
||||||
|
|
||||||
|
import Holder
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val j = Holder(0.99)
|
||||||
|
return if (j.value > 0) "OK" else "fail"
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// reason - multifile tests are not supported in JS tests
|
||||||
|
//FILE: JavaClass.java
|
||||||
|
import org.jetbrains.annotations.*;
|
||||||
|
|
||||||
|
class JavaClass {
|
||||||
|
public static @NotNull Long get() { return 2364137526064485012L; }
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: test.kt
|
||||||
|
|
||||||
|
import JavaClass
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return if (JavaClass.get() > 0) "OK" else "fail"
|
||||||
|
}
|
||||||
+10
@@ -1101,6 +1101,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedLong.kt");
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedLong.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compareWithBoxedNotNullDouble.kt")
|
||||||
|
public void testCompareWithBoxedNotNullDouble() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedNotNullDouble.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compareWithBoxedNotNullLong.kt")
|
||||||
|
public void testCompareWithBoxedNotNullLong() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedNotNullLong.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("divisionByZero.kt")
|
@TestMetadata("divisionByZero.kt")
|
||||||
public void testDivisionByZero() throws Exception {
|
public void testDivisionByZero() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/binaryOp/divisionByZero.kt");
|
runTest("compiler/testData/codegen/box/binaryOp/divisionByZero.kt");
|
||||||
|
|||||||
+10
@@ -1101,6 +1101,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedLong.kt");
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedLong.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compareWithBoxedNotNullDouble.kt")
|
||||||
|
public void testCompareWithBoxedNotNullDouble() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedNotNullDouble.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compareWithBoxedNotNullLong.kt")
|
||||||
|
public void testCompareWithBoxedNotNullLong() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedNotNullLong.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("divisionByZero.kt")
|
@TestMetadata("divisionByZero.kt")
|
||||||
public void testDivisionByZero() throws Exception {
|
public void testDivisionByZero() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/binaryOp/divisionByZero.kt");
|
runTest("compiler/testData/codegen/box/binaryOp/divisionByZero.kt");
|
||||||
|
|||||||
+10
@@ -1081,6 +1081,16 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedLong.kt");
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedLong.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compareWithBoxedNotNullDouble.kt")
|
||||||
|
public void testCompareWithBoxedNotNullDouble() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedNotNullDouble.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compareWithBoxedNotNullLong.kt")
|
||||||
|
public void testCompareWithBoxedNotNullLong() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedNotNullLong.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("divisionByZero.kt")
|
@TestMetadata("divisionByZero.kt")
|
||||||
public void testDivisionByZero() throws Exception {
|
public void testDivisionByZero() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/binaryOp/divisionByZero.kt");
|
runTest("compiler/testData/codegen/box/binaryOp/divisionByZero.kt");
|
||||||
|
|||||||
+10
@@ -1081,6 +1081,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedLong.kt");
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedLong.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compareWithBoxedNotNullDouble.kt")
|
||||||
|
public void testCompareWithBoxedNotNullDouble() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedNotNullDouble.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compareWithBoxedNotNullLong.kt")
|
||||||
|
public void testCompareWithBoxedNotNullLong() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/binaryOp/compareWithBoxedNotNullLong.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("divisionByZero.kt")
|
@TestMetadata("divisionByZero.kt")
|
||||||
public void testDivisionByZero() throws Exception {
|
public void testDivisionByZero() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/binaryOp/divisionByZero.kt");
|
runTest("compiler/testData/codegen/box/binaryOp/divisionByZero.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user