KT-877 - wrong codegen for unary plus

This commit is contained in:
Alex Tkachman
2012-01-02 09:49:04 +02:00
parent c3725054eb
commit cde54d59bd
3 changed files with 19 additions and 1 deletions
@@ -21,7 +21,12 @@ public class UnaryPlus implements IntrinsicMethod {
if(nullable) {
expectedType = JetTypeMapper.unboxType(expectedType);
}
receiver.put(expectedType, v);
if(receiver != null && receiver != StackValue.none())
receiver.put(expectedType, v);
else {
assert arguments != null;
codegen.gen(arguments.get(0), expectedType);
}
return StackValue.onStack(expectedType);
}
}
@@ -0,0 +1,9 @@
fun box() : String {
var a : Int = -1
if((+a) != -1) return "fail 1"
a = 1
if((+a) != 1) return "fail 2"
if((+-1) != -1) return "fail 3"
if((-+a) != -1) return "fail 4"
return "OK"
}
@@ -351,4 +351,8 @@ public class PrimitiveTypesTest extends CodegenTestCase {
public void testKt757 () {
blackBoxFile("regressions/kt757.jet");
}
public void testKt877 () {
blackBoxFile("regressions/kt877.jet");
}
}