use of org.jetbrains.kotlin.psi.ValueArgument in project kotlin by JetBrains.
the class ArrayAccessTranslator method contextWithValueParameterAliasInArrayGetAccess.
// this is hack for a[b]++ -> a.set(b, a.get(b) + 1). Frontend generate fake expression for a.get(b) + 1.
@NotNull
private TranslationContext contextWithValueParameterAliasInArrayGetAccess(@NotNull JsExpression toSetTo) {
ResolvedCall<FunctionDescriptor> resolvedCall = BindingUtils.getResolvedCallForArrayAccess(bindingContext(), expression, /*isGetter = */
false);
List<ResolvedValueArgument> arguments = resolvedCall.getValueArgumentsByIndex();
if (arguments == null) {
throw new IllegalStateException("Failed to arrange value arguments by index: " + resolvedCall.getResultingDescriptor());
}
ResolvedValueArgument lastArgument = arguments.get(arguments.size() - 1);
assert lastArgument instanceof ExpressionValueArgument : "Last argument of array-like setter must be ExpressionValueArgument: " + lastArgument;
ValueArgument valueArgument = ((ExpressionValueArgument) lastArgument).getValueArgument();
assert valueArgument != null;
KtExpression element = valueArgument.getArgumentExpression();
return context().innerContextWithAliasesForExpressions(Collections.singletonMap(element, toSetTo));
}
use of org.jetbrains.kotlin.psi.ValueArgument in project kotlin by JetBrains.
the class CallBasedArgumentGenerator method generateExpression.
@Override
protected void generateExpression(int i, @NotNull ExpressionValueArgument argument) {
ValueParameterDescriptor parameter = valueParameters.get(i);
Type type = valueParameterTypes.get(i);
ValueArgument valueArgument = argument.getValueArgument();
assert valueArgument != null;
KtExpression argumentExpression = valueArgument.getArgumentExpression();
assert argumentExpression != null : valueArgument.asElement().getText();
callGenerator.genValueAndPut(parameter, argumentExpression, type, i);
}
Aggregations