KT-935 resolved call used on +=
This commit is contained in:
@@ -1864,12 +1864,23 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
|
||||
private void callAugAssignMethod(JetBinaryExpression expression, CallableMethod callable, Type lhsType, final boolean keepReturnValue) {
|
||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
|
||||
assert resolvedCall != null;
|
||||
|
||||
StackValue value = gen(expression.getLeft());
|
||||
if (keepReturnValue) {
|
||||
value.dupReceiver(v);
|
||||
}
|
||||
value.put(lhsType, v);
|
||||
genToJVMStack(expression.getRight());
|
||||
StackValue receiver = StackValue.onStack(lhsType);
|
||||
|
||||
if(!(resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor)) { // otherwise already
|
||||
receiver = StackValue.receiver(resolvedCall, receiver, this, callable);
|
||||
receiver.put(receiver.type, v);
|
||||
}
|
||||
|
||||
pushTypeArguments(resolvedCall);
|
||||
pushMethodArguments(resolvedCall, callable.getValueParameterTypes());
|
||||
callable.invoke(v);
|
||||
if (keepReturnValue) {
|
||||
value.store(v);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package bottles
|
||||
|
||||
fun box() : String {
|
||||
var bottles = 10
|
||||
while (bottles > 0) {
|
||||
print(bottlesOfBeer(bottles) + " on the wall, ")
|
||||
println(bottlesOfBeer(bottles) + ".")
|
||||
print("Take one down, pass it around, ")
|
||||
if (--bottles == 0) {
|
||||
println("no more bottles of beer on the wall.")
|
||||
}
|
||||
else {
|
||||
println(bottlesOfBeer(bottles) + " on the wall.")
|
||||
}
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun bottlesOfBeer(count : Int) : String {
|
||||
val result = StringBuilder()
|
||||
result += count
|
||||
result += if (count > 1) " bottles of beer" else " bottle of beer"
|
||||
return result.toString() ?: ""
|
||||
}
|
||||
|
||||
// An excerpt from the standard library
|
||||
fun print(message : String) { System.out?.print(message) }
|
||||
fun println(message : String) { System.out?.println(message) }
|
||||
fun StringBuilder.plusAssign(o : Any) { append(o) }
|
||||
val <T> Array<T>.isEmpty : Boolean get() = size == 0
|
||||
@@ -387,4 +387,8 @@ public class PrimitiveTypesTest extends CodegenTestCase {
|
||||
public void testKt945 () {
|
||||
blackBoxFile("regressions/kt945.jet");
|
||||
}
|
||||
|
||||
public void testKt935 () {
|
||||
blackBoxFile("regressions/kt935.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user