KT-757 wrong inv() for long

This commit is contained in:
Alex Tkachman
2011-12-06 13:29:28 +02:00
parent d1acab01cd
commit 5dff5bded9
3 changed files with 21 additions and 1 deletions
@@ -11,12 +11,18 @@ import java.util.List;
/**
* @author yole
* @author alex.tkachman
*/
public class Inv implements IntrinsicMethod {
@Override
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
receiver.put(expectedType, v);
v.iconst(-1);
if(expectedType == Type.LONG_TYPE) {
v.lconst(-1L);
}
else {
v.iconst(-1);
}
v.xor(expectedType);
return StackValue.onStack(expectedType);
}
@@ -0,0 +1,9 @@
namespace demo_long
fun Long?.inv() : Long = this.sure().inv()
fun box() : String {
val x : Long? = 10
System.out?.println(x.inv())
return if(x.inv() == -11.lng) "OK" else "fail"
}
@@ -350,6 +350,11 @@ public class PrimitiveTypesTest extends CodegenTestCase {
public void testKt684 () {
blackBoxFile("regressions/kt684.jet");
// System.out.println(generateToText());
}
public void testKt757 () {
blackBoxFile("regressions/kt757.jet");
// System.out.println(generateToText());
}
}