Cast unary intrinsics to expected type
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user