Don't try to generate optimized "in" for LongRange

#KT-4097 Fixed
This commit is contained in:
Alexander Udalov
2014-01-29 18:47:55 +04:00
parent 9b01f01e17
commit 75ab8ac5ec
5 changed files with 27 additions and 5 deletions
@@ -81,7 +81,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
private static final String CLASS_NO_PATTERN_MATCHED_EXCEPTION = "jet/NoPatternMatchedException";
private static final String CLASS_TYPE_CAST_EXCEPTION = "jet/TypeCastException";
public static final Set<DeclarationDescriptor> INTEGRAL_RANGES = KotlinBuiltIns.getInstance().getIntegralRanges();
private static final Set<DeclarationDescriptor> INTEGRAL_RANGES = KotlinBuiltIns.getInstance().getIntegralRanges();
private int myLastLineNumber = -1;
@@ -0,0 +1,15 @@
fun box(): String {
val shouldBeTrue = 555555555555555555L in 123456789123456789L..987654321987654321L
if (!shouldBeTrue) return "Fail 1"
val shouldBeFalse = 5000000000L in 6000000000L..9000000000L
if (shouldBeFalse) return "Fail 2"
if (123123123123L !in 100100100100L..200200200200L) return "Fail 3"
return when (9876543210) {
in 2000000000L..3333333333L -> "Fail 4"
!in 8888888888L..9999999999L -> "Fail 5"
else -> "OK"
}
}
@@ -4257,6 +4257,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/primitiveTypes/kt3576.kt");
}
@TestMetadata("kt4097.kt")
public void testKt4097() throws Exception {
doTest("compiler/testData/codegen/box/primitiveTypes/kt4097.kt");
}
@TestMetadata("kt4098.kt")
public void testKt4098() throws Exception {
doTest("compiler/testData/codegen/box/primitiveTypes/kt4098.kt");
@@ -16,14 +16,17 @@
package org.jetbrains.jet.codegen.generated;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.File;
import java.util.regex.Pattern;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import java.io.File;
import java.util.regex.Pattern;
import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@@ -284,8 +284,7 @@ public class KotlinBuiltIns {
getBuiltInClassByName("ByteRange"),
getBuiltInClassByName("ShortRange"),
getBuiltInClassByName("CharRange"),
getBuiltInClassByName("IntRange"),
getBuiltInClassByName("LongRange")
getBuiltInClassByName("IntRange")
);
}