when generating coercion, take into account the original type of the expression

This commit is contained in:
Dmitry Jemerov
2015-03-05 11:21:44 +01:00
parent 5370073c05
commit 2767e789fb
3 changed files with 16 additions and 1 deletions
@@ -26,7 +26,8 @@ class CoercionValue(
) : StackValue(castType, value.canHaveSideEffects()) {
override fun putSelector(type: Type, v: InstructionAdapter) {
value.putSelector(castType, v)
value.putSelector(value.type, v)
StackValue.coerce(value.type, castType, v)
StackValue.coerce(castType, type, v)
}
@@ -0,0 +1,8 @@
fun box(): String {
val x: Any = 'A'
var y = 0
if (x is Char) {
y = x.toInt()
}
return if (y == 65) "OK" else "fail"
}
@@ -1588,6 +1588,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/intrinsics"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("charToInt.kt")
public void testCharToInt() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/intrinsics/charToInt.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("defaultObjectMapping.kt")
public void testDefaultObjectMapping() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/intrinsics/defaultObjectMapping.kt");