I'm trying to migrate from the deprecated putValue...
# k2-adopters
x
I'm trying to migrate from the deprecated putValueArgument in IrMemberAccessExpression and need some guidance. There is this brief doc in the source file: "Sets one of arguments that correspond to IrParameterKind.Context or IrParameterKind.Regular parameters. This is, index corresponds to IrFunction.valueParameters list, and not IrFunction.parameters, which also includes receiver parameters. This is a deprecated API! Use arguments instead. E.g. for code call.putValueArgument(parameter.indexInOldValueParameters, ...) the replacement should be call.arguments[parameter.indexInParameters] = ... If you need to know the IrParameterKind of the arguments, reach out to the corresponding function's parameter. Details on the API migration: KT-68003" Say I want to migrate:
Copy code
putValueArgument(0, expr)
I'm not clear on how to get "parameter.indexInParameters" in this case. And where can I find "the API migration: KT-68003"? Any help please.
d
cc @Wojciech Litewka
w
Hi, the migration doc is here. For your question about
putValueArgument
, the kdoc assumes you have an instance of
IrValueParameter
and you want to set an argument that corresponds to it. But if you just specify the index as a constant, you can still do so with
call.arguments[N] = expr
. Please only note that this constant index may now be different, e.g. 1 instead of 0, because you now also have to count receivers and context parameters, if any. More on that in the guide I linked.
👍 1
1