Fix default argument method calls

In some cases, calls of methods with default arguments were invoked via the
actual generated method, not via the "...$default" accessor
This commit is contained in:
Alexander Udalov
2013-09-03 19:57:15 +04:00
parent 329d724c1e
commit 723d5ef564
7 changed files with 74 additions and 7 deletions
@@ -2138,12 +2138,16 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
}
int mask = pushMethodArguments(resolvedCall, callableMethod.getValueParameterTypes());
pushArgumentsAndInvoke(resolvedCall, callableMethod);
}
private void pushArgumentsAndInvoke(@NotNull ResolvedCall<?> resolvedCall, @NotNull CallableMethod callable) {
int mask = pushMethodArguments(resolvedCall, callable.getValueParameterTypes());
if (mask == 0) {
callableMethod.invokeWithNotNullAssertion(v, state, resolvedCall);
callable.invokeWithNotNullAssertion(v, state, resolvedCall);
}
else {
callableMethod.invokeDefaultWithNotNullAssertion(v, state, resolvedCall, mask);
callable.invokeDefaultWithNotNullAssertion(v, state, resolvedCall, mask);
}
}
@@ -2947,8 +2951,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
receiver.put(receiver.type, v);
}
pushMethodArguments(resolvedCall, callable.getValueParameterTypes());
callable.invokeWithNotNullAssertion(v, state, resolvedCall);
pushArgumentsAndInvoke(resolvedCall, callable);
if (keepReturnValue) {
value.store(callable.getReturnType(), v);
}
@@ -3038,8 +3042,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null;
genThisAndReceiverFromResolvedCall(StackValue.none(), resolvedCall, callable);
pushMethodArguments(resolvedCall, callable.getValueParameterTypes());
callable.invokeWithNotNullAssertion(v, state, resolvedCall);
pushArgumentsAndInvoke(resolvedCall, callable);
return returnValueAsStackValue(op, callable.getSignature().getAsmMethod().getReturnType());
}