When updating from 2.2.0 to 2.2.20-Beta1 got compi...
# compiler
p
When updating from 2.2.0 to 2.2.20-Beta1 got compilation error for Js and WasmJs targets
generated invalid IR. Please report this bug to the plugin vendor. Inconsistent index (old API) of value parameter 1 != 0
For Jvm target or Kotlin version less then 2.2.20-Beta1 compilation succeed (using the same transformation logic). I'm using old (deprecated) methods for working with parameters. Before digging into this issue i want to ask if there is any advice for this error message?
d
cc @Wojciech Litewka
w
Maybe you call a setter of one of
IrValueParameter.index*
properties? If so please try to remove it, it is not necessary now.
p
I'm not changing indexes of
IrValueParameter
manually. I'm only using IrMemberAccessExpression::putValueArgument(index,expression) or IrMemberAccessExpression::dispatchReceiver
I've made facade for working with paramaters and for now i'm using old api as implementation
Copy code
@OptIn(DeprecatedForRemovalCompilerApi::class)  // TODO
    fun paramPutTypeArgument(call: IrMemberAccessExpression<*>, index: Int, type: IrType?) {
        call.putTypeArgument(index, type)
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramDispatcherReceiverSet(func: IrFunction, param: IrValueParameter?) {
        func.dispatchReceiverParameter = param
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramDispatcherReceiverSet(call: IrMemberAccessExpression<*>, value: IrExpression?) {
        call.dispatchReceiver = value
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramExtensionReceiver(func: IrFunction): IrValueParameter? {
        return func.extensionReceiverParameter
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramExtensionReceiverValueSet(call: IrMemberAccessExpression<*>, param: IrExpression?) {
        call.extensionReceiver = param
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramValueParameters(func: IrFunction): List<IrValueParameter> {
        return func.valueParameters
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramValueParametersIsEmpty(func: IrFunction): Boolean {
        return func.valueParameters.isEmpty()
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramValueParametersSize(func: IrFunction): Int {
        return func.valueParameters.size
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramValueParametersSet(func: IrFunction, params: List<IrValueParameter>) {
        func.valueParameters = params
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramValueParameter(func: IrFunction, index: Int): IrValueParameter {
        return func.valueParameters[index]
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class) // TODO
    fun paramValueParameterOrNull(func: IrFunction, index: Int): IrValueParameter? {
        return func.valueParameters.getOrNull(index)
    }

    @OptIn(DeprecatedForRemovalCompilerApi::class)  // TODO
    fun paramPutValueArgument(call: IrMemberAccessExpression<*>, index: Int, valueArgument: IrExpression?) {
        call.putValueArgument(index, valueArgument)
    }
So i'm working with parameters only through this api
I've found the cause. It happens when overriding fakeOverride function and setting (replacing) dispatchReceiverParameter with new one with concrete type (may be it will be the same with any function replacing dispatcher receiver). Now i just changing type of current dispatchReceiverParameter and it starts to compile
But anyway is it supposed to work such way? May be after setting dispatchReceiverParamater other value parameters indexes need to be recalculated?
And one more thing - why for JVM target such check was ignored?