Cast unary intrinsics to expected type

This commit is contained in:
Natalia Ukhorskaya
2013-12-16 14:04:18 +04:00
parent 20aa3409c7
commit 4ef1af7d12
3 changed files with 16 additions and 1 deletions
@@ -53,6 +53,8 @@ public class UnaryMinus implements IntrinsicMethod {
else {
receiver.put(operandType, v);
}
return StackValue.onStack(genNegate(returnType, v));
Type negatedValue = genNegate(returnType, v);
StackValue.coerce(negatedValue, returnType, v);
return StackValue.onStack(returnType);
}
}
@@ -0,0 +1,8 @@
fun box(): String {
if (!foo(1.toByte())) return "fail 1"
if (!foo(-1.toByte())) return "fail 2"
return "OK"
}
fun foo(p: Any) = p is Byte
@@ -4845,6 +4845,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/unaryOp/callNullable.kt");
}
@TestMetadata("callWithCommonType.kt")
public void testCallWithCommonType() throws Exception {
doTest("compiler/testData/codegen/box/unaryOp/callWithCommonType.kt");
}
@TestMetadata("intrinsic.kt")
public void testIntrinsic() throws Exception {
doTest("compiler/testData/codegen/box/unaryOp/intrinsic.kt");