KT-2485 fix - coercion boolean to Any? etc.
This commit is contained in:
@@ -66,6 +66,7 @@ public class JetTypeMapper {
|
||||
public static final Type JL_CHAR_SEQUENCE_TYPE = Type.getObjectType("java/lang/CharSequence");
|
||||
private static final Type JL_COMPARABLE_TYPE = Type.getObjectType("java/lang/Comparable");
|
||||
public static final Type JL_CLASS_TYPE = Type.getObjectType("java/lang/Class");
|
||||
public static final Type JL_BOOLEAN_TYPE = Type.getObjectType("java/lang/Boolean");
|
||||
|
||||
public static final Type ARRAY_GENERIC_TYPE = Type.getType(Object[].class);
|
||||
public static final Type TUPLE0_TYPE = Type.getObjectType("jet/Tuple0");
|
||||
|
||||
@@ -447,10 +447,12 @@ public abstract class StackValue {
|
||||
putTuple0Instance(v);
|
||||
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 " + type);
|
||||
}
|
||||
putAsBoolean(v);
|
||||
if(type != Type.BOOLEAN_TYPE)
|
||||
box(Type.BOOLEAN_TYPE,type,v);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
fun f1(a : Any?) {}
|
||||
fun f2(a : Boolean?) {}
|
||||
fun f3(a : Any) {}
|
||||
fun f4(a : Boolean) {}
|
||||
|
||||
fun box() : String {
|
||||
f1(1 == 1)
|
||||
f2(1 == 1)
|
||||
f3(1 == 1)
|
||||
f4(1 == 1)
|
||||
return "OK"
|
||||
}
|
||||
@@ -481,4 +481,9 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxMultiFile("regressions/kt2566_2.kt");
|
||||
}
|
||||
|
||||
public void testKt2485() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxMultiFile("regressions/kt2485.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user