Boxing values merge fix. #KT-5588 Fixed

When merging Boxed value and something else just return MIXED_VALUE
This commit is contained in:
Denis Zharkov
2014-08-04 20:57:02 +04:00
committed by Evgeny Gerashchenko
parent 81f7ace128
commit e0ced7cbcf
4 changed files with 18 additions and 3 deletions
@@ -221,12 +221,12 @@ public class BoxingInterpreter extends OptimizationBasicInterpreter {
if (v instanceof BoxedBasicValue) {
onMergeFail((BoxedBasicValue) v);
v = new BasicValue(v.getType());
return MIXED_VALUE;
}
if (w instanceof BoxedBasicValue) {
onMergeFail((BoxedBasicValue) w);
w = new BasicValue(w.getType());
return MIXED_VALUE;
}
return super.merge(v, w);
@@ -27,7 +27,7 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.BasicInterpreter;
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue;
public class OptimizationBasicInterpreter extends BasicInterpreter {
private static final BasicValue MIXED_VALUE = new BasicValue(Type.getObjectType("#"));
public static final BasicValue MIXED_VALUE = new BasicValue(Type.getObjectType("#"));
private static final BasicValue BOOLEAN_VALUE = new BasicValue(Type.BOOLEAN_TYPE);
private static final BasicValue CHAR_VALUE = new BasicValue(Type.CHAR_TYPE);
private static final BasicValue BYTE_VALUE = new BasicValue(Type.BYTE_TYPE);
@@ -0,0 +1,10 @@
fun box() : String {
val s = "notA"
val id = when (s) {
"a" -> 1
else -> null
}
if (id == null) return "OK"
return "fail"
}
@@ -134,6 +134,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/boxingOptimization/kt5493.kt");
}
@TestMetadata("kt5588.kt")
public void testKt5588() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/boxingOptimization/kt5588.kt");
}
@TestMetadata("nullCheck.kt")
public void testNullCheck() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/boxingOptimization/nullCheck.kt");