diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt index 43217a215b8..bcfdcfe2134 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ArrayConstructorLowering.kt @@ -96,7 +96,11 @@ private class ArrayConstructorTransformer( putValueArgument(1, inlined) } val inc = index.type.getClass()!!.functions.single { it.name == OperatorNameConventions.INC } - +irSet(index.symbol, irCallOp(inc.symbol, index.type, irGet(index))) + +irSet( + index.symbol, + irCallOp(inc.symbol, index.type, irGet(index)), + origin = IrStatementOrigin.PREFIX_INCR + ) } } +irGet(result) @@ -112,7 +116,11 @@ class ArrayConstructorReferenceLowering(val context: CommonBackendContext) : Bod irBody.transformChildrenVoid(ArrayConstructorReferenceTransformer(context, container as IrSymbolOwner)) } - private class ArrayConstructorReferenceTransformer(val context: CommonBackendContext, val container: IrSymbolOwner) : IrElementTransformerVoid() { + private class ArrayConstructorReferenceTransformer( + val context: CommonBackendContext, + val container: IrSymbolOwner + ) : IrElementTransformerVoid() { + override fun visitFunctionReference(expression: IrFunctionReference): IrExpression { expression.transformChildrenVoid() val target = expression.symbol.owner @@ -127,14 +135,12 @@ class ArrayConstructorReferenceLowering(val context: CommonBackendContext) : Bod statements.add(wrapper) statements.add( IrFunctionReferenceImpl( - startOffset, - endOffset, - type, - wrapper.symbol, - 0, - valueArgumentsCount, - target.symbol, - origin + startOffset, endOffset, type, + symbol = wrapper.symbol, + typeArgumentsCount = 0, + valueArgumentsCount = valueArgumentsCount, + reflectionTarget = target.symbol, + origin = origin ) ) } diff --git a/compiler/testData/codegen/bytecodeText/forLoop/intrinsicArrayConstructorsUseCounterLoop.kt b/compiler/testData/codegen/bytecodeText/forLoop/intrinsicArrayConstructorsUseCounterLoop.kt index 1972b9b6e55..6da8d09686d 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/intrinsicArrayConstructorsUseCounterLoop.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/intrinsicArrayConstructorsUseCounterLoop.kt @@ -38,8 +38,8 @@ fun testObjectArray(n: Int) = // 8 IF_ICMPGE // JVM_IR_TEMPLATES -// 56 ILOAD -// 24 ISTORE -// 8 IADD +// 48 ILOAD +// 16 ISTORE +// 0 IADD // 0 ISUB -// 0 IINC \ No newline at end of file +// 8 IINC diff --git a/compiler/testData/codegen/bytecodeText/storeStackBeforeInline/arrayConstructor.kt b/compiler/testData/codegen/bytecodeText/storeStackBeforeInline/arrayConstructor.kt index c1294b531ff..4add3c00e01 100644 --- a/compiler/testData/codegen/bytecodeText/storeStackBeforeInline/arrayConstructor.kt +++ b/compiler/testData/codegen/bytecodeText/storeStackBeforeInline/arrayConstructor.kt @@ -11,5 +11,5 @@ fun test(): Int = "123".indexOfAny(CharArray(1000) { '1' }) // JVM_IR_TEMPLATES: // 3 ALOAD // 3 ASTORE -// 4 ILOAD -// 3 ISTORE +// 3 ILOAD +// 2 ISTORE