I have a lambda with its `it` value parameter bein...
# compiler
j
I have a lambda with its
it
value parameter being used in its body.
Copy code
foo.increase {
   it + 42
}
I want to create a different lambda, and replace
increase
with it, but reusing its
body
Copy code
foo.newLambda {
    it + 42
}
The problem is the
it
is not in the mapper so it fails. Indeed I got issues related to the parent in the
IrReturn
when I tested it without using
it
and I did the next workaround:
Copy code
this.body = declarationIrBuilder(this).irBlockBody {
    for (original in originalStatements) {
        val statement: IrStatement =
            if (original is IrReturn) irReturn(original.value)
            else original
        +statement
    }
}
Is there a simple way to just copy the
body
an map the parent and the value parameters? I tried
deepCopyWithSymbols
and indicating a parent but it did not work.
Instead of copying the
body
I am copying the whole function and it works
Copy code
val expressionLambdaFunction: IrSimpleFunction =
    expressionLambda?.deepCopyWithSymbols(updateCallParent)?.function