Change interpretCall to be able to interpret data class copy method

This commit is contained in:
Ivan Kylchik
2020-02-20 13:05:25 +03:00
parent bab4407c0a
commit 6a9f4cf8b7
@@ -398,8 +398,9 @@ class IrInterpreter(irModule: IrModuleFragment) {
// if irFunction is lambda and it has receiver, then first descriptor must be taken from extension receiver
val receiverAsFirstArgument = if (dispatchReceiver is Lambda) listOfNotNull(irFunction.symbol.getExtensionReceiver()) else listOf()
val valueParametersDescriptors = receiverAsFirstArgument + irFunction.descriptor.valueParameters
interpretValueParameters(expression, data).also { if (it != Code.NEXT) return it }
newFrame.addAll(valueParametersDescriptors.map { Variable(it, data.popReturnValue()) })
val frameWithReceiverAndData = data.copy().apply { addAll(newFrame.getAll()) } // primary use case: copy method in data class
interpretValueParameters(expression, frameWithReceiverAndData).also { if (it != Code.NEXT) return it }
newFrame.addAll(valueParametersDescriptors.map { Variable(it, frameWithReceiverAndData.popReturnValue()) })
irFunction.takeIf { it.isInline }?.typeParameters?.forEachIndexed { index, typeParameter ->
if (typeParameter.isReified) {