Fix for KT-11584: Regression in 1.0.1: incorrect comparison of Long! with integer constant

#KT-11584 Fixed
This commit is contained in:
Michael Bogdanov
2016-03-23 17:23:00 +01:00
parent 628f9050fb
commit a851bb0fff
3 changed files with 20 additions and 1 deletions
@@ -3138,7 +3138,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
Type leftType = expressionType(left);
Type rightType = expressionType(right);
Callable callable = resolveToCallable((FunctionDescriptor) resolvedCall.getResultingDescriptor(), false, resolvedCall);
if (callable instanceof IntrinsicCallable) {
if (isPrimitive(leftType) && isPrimitive(rightType) && callable instanceof IntrinsicCallable) {
type = comparisonOperandType(leftType, rightType);
leftValue = gen(left);
rightValue = gen(right);
@@ -0,0 +1,13 @@
//FILE: JavaClass.java
class JavaClass {
public static Long get() { return 2364137526064485012L; }
}
//FILE: test.kt
import JavaClass
fun box(): String {
return if (JavaClass.get() > 0) "OK" else "fail"
}
@@ -730,6 +730,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("compareWithBoxedLong.kt")
public void testCompareWithBoxedLong() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/compareWithBoxedLong.kt");
doTest(fileName);
}
@TestMetadata("divisionByZero.kt")
public void testDivisionByZero() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/divisionByZero.kt");