Merge pull request #617 from JetBrains/rr/yole/number-toint
when generating coercion, take into account the original type of the exp...
This commit is contained in:
@@ -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"
|
||||
}
|
||||
+6
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user