KT-613 verify error ++/-- in presence of this|receiver
This commit is contained in:
@@ -5,6 +5,7 @@ import org.jetbrains.jet.codegen.ExpressionCodegen;
|
|||||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||||
import org.jetbrains.jet.codegen.StackValue;
|
import org.jetbrains.jet.codegen.StackValue;
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetParenthesizedExpression;
|
||||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.commons.InstructionAdapter;
|
import org.objectweb.asm.commons.InstructionAdapter;
|
||||||
@@ -23,7 +24,10 @@ public class Increment implements IntrinsicMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
final JetExpression operand = arguments.get(0);
|
JetExpression operand = arguments.get(0);
|
||||||
|
while(operand instanceof JetParenthesizedExpression) {
|
||||||
|
operand = ((JetParenthesizedExpression)operand).getExpression();
|
||||||
|
}
|
||||||
if (operand instanceof JetReferenceExpression) {
|
if (operand instanceof JetReferenceExpression) {
|
||||||
final int index = codegen.indexOfLocal((JetReferenceExpression) operand);
|
final int index = codegen.indexOfLocal((JetReferenceExpression) operand);
|
||||||
if (index >= 0 && JetTypeMapper.isIntPrimitive(expectedType)) {
|
if (index >= 0 && JetTypeMapper.isIntPrimitive(expectedType)) {
|
||||||
@@ -33,6 +37,7 @@ public class Increment implements IntrinsicMethod {
|
|||||||
}
|
}
|
||||||
StackValue value = codegen.genQualified(receiver, operand);
|
StackValue value = codegen.genQualified(receiver, operand);
|
||||||
value. dupReceiver(v);
|
value. dupReceiver(v);
|
||||||
|
value. dupReceiver(v);
|
||||||
value.put(expectedType, v);
|
value.put(expectedType, v);
|
||||||
if (expectedType == Type.LONG_TYPE) {
|
if (expectedType == Type.LONG_TYPE) {
|
||||||
v.lconst(myDelta);
|
v.lconst(myDelta);
|
||||||
@@ -44,10 +49,11 @@ public class Increment implements IntrinsicMethod {
|
|||||||
v.dconst(myDelta);
|
v.dconst(myDelta);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
v.aconst(myDelta);
|
v.iconst(myDelta);
|
||||||
}
|
}
|
||||||
v.add(expectedType);
|
v.add(expectedType);
|
||||||
value.store(v);
|
value.store(v);
|
||||||
return value;
|
value.put(expectedType, v);
|
||||||
|
return StackValue.onStack(expectedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace name
|
||||||
|
|
||||||
|
class Test() {
|
||||||
|
var i = 5
|
||||||
|
val ten = 10.lng
|
||||||
|
|
||||||
|
fun Long.t() = this.int + i++ + ++i
|
||||||
|
|
||||||
|
fun tt() = ten.t()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() : String {
|
||||||
|
var m = Test()
|
||||||
|
return if((m.i)++ == 5 && ++(m.i) == 7 && m.tt() == 26) "OK" else "fail"
|
||||||
|
}
|
||||||
@@ -136,6 +136,10 @@ public class PropertyGenTest extends CodegenTestCase {
|
|||||||
blackBoxFile("regressions/kt257.jet");
|
blackBoxFile("regressions/kt257.jet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt613 () throws Exception {
|
||||||
|
blackBoxFile("regressions/kt613.jet");
|
||||||
|
}
|
||||||
|
|
||||||
public void testKt160() throws Exception {
|
public void testKt160() throws Exception {
|
||||||
loadText("internal val s = java.lang.Double.toString(1.0)");
|
loadText("internal val s = java.lang.Double.toString(1.0)");
|
||||||
final Method method = generateFunction("getS");
|
final Method method = generateFunction("getS");
|
||||||
|
|||||||
Reference in New Issue
Block a user