KT-2334 partly fix: boolean to object coercion

This commit is contained in:
Alex Tkachman
2012-08-04 12:46:49 +03:00
parent 301b55788e
commit 34a0b0dcd4
3 changed files with 21 additions and 2 deletions
@@ -447,7 +447,7 @@ public abstract class StackValue {
putTuple0Instance(v);
return;
}
if (type != Type.BOOLEAN_TYPE && type.equals(JetTypeMapper.TYPE_OBJECT) && type.equals(JetTypeMapper.JL_BOOLEAN_TYPE)) {
if (type != Type.BOOLEAN_TYPE && !type.equals(JetTypeMapper.TYPE_OBJECT) && !type.equals(JetTypeMapper.JL_BOOLEAN_TYPE)) {
throw new UnsupportedOperationException("don't know how to put a compare as a non-boolean type " + type);
}
putAsBoolean(v);
@@ -534,10 +534,12 @@ public abstract class StackValue {
myOperand.put(type, v); // the operand will remove itself from the stack if needed
return;
}
if (type != Type.BOOLEAN_TYPE) {
if (type != Type.BOOLEAN_TYPE && !type.equals(JetTypeMapper.TYPE_OBJECT) && !type.equals(JetTypeMapper.JL_BOOLEAN_TYPE)) {
throw new UnsupportedOperationException("don't know how to put a compare as a non-boolean type");
}
putAsBoolean(v);
if(type != Type.BOOLEAN_TYPE)
box(Type.BOOLEAN_TYPE,type,v);
}
@Override
@@ -0,0 +1,13 @@
import kotlin.test.*
import org.junit.Test as test
public class Test {
test fun f(): Unit {
assertEquals(true, !false)
}
}
fun box() : String {
Test().f()
return "OK"
}
@@ -337,6 +337,10 @@ public class StdlibTest extends CodegenTestCase {
blackBoxFile("regressions/kt1800.kt");
}
public void testKt2334() {
blackBoxFile("regressions/kt2334.kt");
}
public void testUptoDownto() {
blackBoxFile("uptoDownto.kt");
}