From 2b986194fb15f8044c40c66c23230c6f4caa3293 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 16 Mar 2020 17:00:08 +0300 Subject: [PATCH] [FIR] Add desugaring of array assignments and resolve of it #KT-37516 Fixed --- .../kotlin/fir/backend/Fir2IrVisitor.kt | 1 + .../converter/ExpressionsConverter.kt | 4 +- .../kotlin/fir/builder/BaseFirBuilder.kt | 169 ++++++++++++++---- .../kotlin/fir/builder/RawFirBuilder.kt | 2 +- .../kotlin/fir/resolve/dfa/VariableStorage.kt | 1 - .../body/resolve/FirBodyResolveTransformer.kt | 4 + .../FirExpressionsResolveTransformer.kt | 61 ++++++- .../testData/resolve/arrays/arraySet.kt | 31 ++++ .../testData/resolve/arrays/arraySet.txt | 55 ++++++ .../resolve/arrays/arraySetWithOperation.kt | 36 ++++ .../resolve/arrays/arraySetWithOperation.txt | 63 +++++++ .../fir/FirDiagnosticsTestGenerated.java | 23 +++ ...DiagnosticsWithLightTreeTestGenerated.java | 23 +++ .../kotlin/fir/expressions/FirArraySetCall.kt | 30 +--- .../builder/FirArraySetCallBuilder.kt | 35 ++-- .../expressions/impl/FirArraySetCallImpl.kt | 96 ++-------- .../org/jetbrains/kotlin/fir/FirRenderer.kt | 10 +- .../fir/tree/generator/BuilderConfigurator.kt | 5 +- .../fir/tree/generator/FirTreeBuilder.kt | 2 +- .../generator/ImplementationConfigurator.kt | 8 - .../fir/tree/generator/NodeConfigurator.kt | 6 +- .../codegen/box/arrays/arrayPlusAssign.kt | 1 - .../arrays/collectionAssignGetMultiIndex.kt | 1 - compiler/testData/codegen/box/arrays/kt33.kt | 2 +- .../codegen/box/arrays/longAsIndex.kt | 1 - .../codegen/box/arrays/multiDecl/kt15560.kt | 1 - .../testData/codegen/box/classes/kt508.kt | 1 - .../capturedInInlineOnlyIndexedCAO.kt | 1 - .../plusAssignWithDefaultInGetter.kt | 1 - ...ArrayAccessToPropertyImportedFromObject.kt | 1 - .../box/operatorConventions/overloadedSet.kt | 1 - .../platformTypes/primitives/plusAssign.kt | 1 - .../codegen/box/private/arrayConvention.kt | 1 - .../InconsistentGetSet.fir.kt | 6 +- .../plusAssignOnArray.fir.kt | 2 +- .../tests/regressions/kt10633.fir.kt | 2 +- .../arrayAugmentedAssignment1.fir.txt | 36 +++- .../arrayAugmentedAssignment2.fir.txt | 15 +- .../caoWithAdaptationForSam.fir.txt | 60 ++++++- .../ir/irText/expressions/kt28456.fir.txt | 19 +- .../ir/irText/expressions/lambdaInCAO.fir.txt | 23 ++- 41 files changed, 608 insertions(+), 233 deletions(-) create mode 100644 compiler/fir/resolve/testData/resolve/arrays/arraySet.kt create mode 100644 compiler/fir/resolve/testData/resolve/arrays/arraySet.txt create mode 100644 compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.kt create mode 100644 compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 1e83eb5f7bd..5a219df7a3c 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -856,6 +856,7 @@ class Fir2IrVisitor( private fun FirStatement.toIrStatement(): IrStatement? { if (this is FirTypeAlias) return null if (this is FirUnitExpression) return toIrExpression() + if (this is FirBlock) return toIrExpression() return accept(this@Fir2IrVisitor, null) as IrStatement } diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index 74db95859c6..dbb520fe87c 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -192,6 +192,7 @@ class ExpressionsConverter( lateinit var operationTokenName: String var leftArgNode: LighterASTNode? = null var rightArgAsFir: FirExpression = buildErrorExpression(null, FirSimpleDiagnostic("No right operand", DiagnosticKind.Syntax)) + var rightArg: LighterASTNode? = null binaryExpression.forEachChildren { when (it.tokenType) { OPERATION_REFERENCE -> { @@ -203,6 +204,7 @@ class ExpressionsConverter( leftArgNode = it } else { rightArgAsFir = getAsFirExpression(it, "No right operand") + rightArg = it } } } @@ -241,7 +243,7 @@ class ExpressionsConverter( } else { val firOperation = operationToken.toFirOperation() if (firOperation in FirOperation.ASSIGNMENTS) { - return leftArgNode.generateAssignment(null, rightArgAsFir, firOperation) { getAsFirExpression(this) } + return leftArgNode.generateAssignment(null, rightArg, rightArgAsFir, firOperation) { getAsFirExpression(this) } } else { buildOperatorCall { source = binaryExpression.toFirSourceElement() diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt index 344173c1ce3..d105f0eecc8 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt @@ -11,10 +11,7 @@ import org.jetbrains.kotlin.KtNodeTypes.* import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.* -import org.jetbrains.kotlin.fir.declarations.FirConstructor -import org.jetbrains.kotlin.fir.declarations.FirProperty -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.declarations.addDeclaration +import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.* import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind @@ -42,6 +39,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtStringTemplateExpression import org.jetbrains.kotlin.psi.KtUnaryExpression import org.jetbrains.kotlin.resolve.constants.evaluate.* +import org.jetbrains.kotlin.util.OperatorNameConventions //T can be either PsiElement, or LighterASTNode abstract class BaseFirBuilder(val baseSession: FirSession, val context: Context = Context()) { @@ -387,6 +385,7 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte val resultVar = generateTemporaryVariable(this@BaseFirBuilder.baseSession, source, resultName, resultInitializer) val assignment = argument.generateAssignment( source, + argument, if (prefix && argument.elementType != REFERENCE_EXPRESSION) generateResolvedAccessExpression(source, resultVar) else @@ -463,48 +462,24 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte fun T?.generateAssignment( baseSource: FirSourceElement?, - value: FirExpression, + rhs: T?, + value: FirExpression, // value is FIR for rhs operation: FirOperation, convert: T.() -> FirExpression ): FirStatement { val tokenType = this?.elementType if (tokenType == PARENTHESIZED) { - return this!!.getExpressionInParentheses().generateAssignment(baseSource, value, operation, convert) + return this!!.getExpressionInParentheses().generateAssignment(baseSource, rhs, value, operation, convert) } if (tokenType == ARRAY_ACCESS_EXPRESSION) { + require(this != null) if (operation == FirOperation.ASSIGN) { - context.arraySetArgument[this!!] = value + context.arraySetArgument[this] = value } - val firArrayAccess = this!!.convert() as FirFunctionCall - if (operation == FirOperation.ASSIGN) { - return firArrayAccess - } - val arraySetCallBuilder = FirArraySetCallBuilder().apply { - source = baseSource - rValue = value - this.operation = operation - indexes += firArrayAccess.arguments - argumentList = buildArraySetArgumentList(rValue, indexes) - } - val arrayExpression = this.getChildNodeByType(REFERENCE_EXPRESSION) - if (arrayExpression != null) { - return arraySetCallBuilder.apply { - calleeReference = initializeLValue(arrayExpression) { convert() as? FirQualifiedAccess } - }.build() - } - val psiArrayExpression = firArrayAccess.explicitReceiver?.psi - return buildBlock { - source = psiArrayExpression?.toFirSourceElement() - val name = Name.special("") - statements += generateTemporaryVariable( - this@BaseFirBuilder.baseSession, this@generateAssignment.getSourceOrNull(), name, firArrayAccess.explicitReceiver!! - ) - statements += arraySetCallBuilder.apply { - calleeReference = buildSimpleNamedReference { - source = psiArrayExpression?.toFirSourceElement() - this.name = name - } - }.build() + return if (operation == FirOperation.ASSIGN) { + this.convert() + } else { + generateArraySetCall(baseSource, operation, rhs, convert) } } @@ -531,6 +506,120 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte } } + private fun T.generateArraySetCall( + baseSource: FirSourceElement?, + operation: FirOperation, + rhs: T?, + convert: T.() -> FirExpression + ): FirStatement { + return buildArraySetCall { + source = baseSource + this.operation = operation + assignCall = generateAugmentedCallForAugmentedArraySetCall(operation, rhs, convert) + setGetBlock = generateSetGetBlockForAugmentedArraySetCall(baseSource, operation, rhs, convert) + } + } + + private fun T.generateAugmentedCallForAugmentedArraySetCall( + operation: FirOperation, + rhs: T?, + convert: T.() -> FirExpression + ): FirFunctionCall { + /* + * Desugarings of a[x, y] += z to + * a.get(x, y).plusAssign(z) + */ + return buildFunctionCall { + calleeReference = buildSimpleNamedReference { + name = FirOperationNameConventions.ASSIGNMENTS.getValue(operation) + } + explicitReceiver = convert() + argumentList = buildArgumentList { + arguments += rhs?.convert() ?: buildErrorExpression( + null, + FirSimpleDiagnostic("No value for array set", DiagnosticKind.Syntax) + ) + } + } + } + + + private fun T.generateSetGetBlockForAugmentedArraySetCall( + baseSource: FirSourceElement?, + operation: FirOperation, + rhs: T?, + convert: T.() -> FirExpression + ): FirBlock { + /* + * Desugarings of a[x, y] += z to + * { + * val tmp_a = a + * val tmp_x = x + * val tmp_y = y + * tmp_a.set(tmp_x, tmp_a.get(tmp_x, tmp_y).plus(z)) + * } + */ + return buildBlock { + val baseCall = convert() as FirFunctionCall + + val arrayVariable = generateTemporaryVariable( + baseSession, + source = null, + "", + baseCall.explicitReceiver ?: buildErrorExpression { + source = baseSource + diagnostic = FirSimpleDiagnostic("No receiver for array access", DiagnosticKind.Syntax) + } + ) + statements += arrayVariable + val indexVariables = baseCall.arguments.mapIndexed { i, index -> + generateTemporaryVariable(baseSession, source = null, "", index) + } + statements += indexVariables + statements += buildFunctionCall { + source = baseSource + explicitReceiver = arrayVariable.toQualifiedAccess() + calleeReference = buildSimpleNamedReference { + name = OperatorNameConventions.SET + } + argumentList = buildArgumentList { + for (indexVariable in indexVariables) { + arguments += indexVariable.toQualifiedAccess() + } + + val getCall = buildFunctionCall { + explicitReceiver = arrayVariable.toQualifiedAccess() + calleeReference = buildSimpleNamedReference { + name = OperatorNameConventions.GET + } + argumentList = buildArgumentList { + for (indexVariable in indexVariables) { + arguments += indexVariable.toQualifiedAccess() + } + } + } + + val operatorCall = buildFunctionCall { + calleeReference = buildSimpleNamedReference { + name = FirOperationNameConventions.ASSIGNMENTS_TO_SIMPLE_OPERATOR.getValue(operation) + } + explicitReceiver = getCall + argumentList = buildArgumentList { + arguments += rhs?.convert() ?: buildErrorExpression( + null, + FirSimpleDiagnostic( + "No value for array set", + DiagnosticKind.Syntax + ) + ) + } + } + arguments += operatorCall + } + } + } + } + fun List>.generateComponentFunctions( session: FirSession, firClassBuilder: AbstractFirRegularClassBuilder, packageFqName: FqName, classFqName: FqName, firPrimaryConstructor: FirConstructor, @@ -631,4 +720,10 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte ) } + private fun FirVariable<*>.toQualifiedAccess(): FirQualifiedAccessExpression = buildQualifiedAccessExpression { + calleeReference = buildResolvedNamedReference { + name = this@toQualifiedAccess.name + resolvedSymbol = this@toQualifiedAccess.symbol + } + } } diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 122b7edf00b..f469d7aa9f8 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -1396,7 +1396,7 @@ class RawFirBuilder( } else { val firOperation = operationToken.toFirOperation() if (firOperation in FirOperation.ASSIGNMENTS) { - return expression.left.generateAssignment(source, rightArgument, firOperation) { + return expression.left.generateAssignment(source, expression.right, rightArgument, firOperation) { (this as KtExpression).toFirExpression("Incorrect expression in assignment: ${expression.text}") } } else { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt index fdddbfd3db8..c903bf60903 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt @@ -70,7 +70,6 @@ class VariableStorage(val session: FirSession) { is FirQualifiedAccessExpression -> originalFir is FirWhenSubjectExpression -> originalFir.whenSubject.whenExpression.subject as? FirQualifiedAccessExpression is FirVariableAssignment -> originalFir - is FirArraySetCall -> originalFir else -> null } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt index e71e1ffdb8c..6081e245e1d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt @@ -169,6 +169,10 @@ open class FirBodyResolveTransformer( return expressionsTransformer.transformDelegatedConstructorCall(delegatedConstructorCall, data) } + override fun transformArraySetCall(arraySetCall: FirArraySetCall, data: ResolutionMode): CompositeTransformResult { + return expressionsTransformer.transformArraySetCall(arraySetCall, data) + } + // ------------------------------------- Declarations ------------------------------------- override fun transformDeclaration(declaration: FirDeclaration, data: ResolutionMode): CompositeTransformResult { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index e7b5735855e..4f3f7156602 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -23,9 +23,7 @@ import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.candidate -import org.jetbrains.kotlin.fir.resolve.diagnostics.FirOperatorAmbiguityError -import org.jetbrains.kotlin.fir.resolve.diagnostics.FirTypeMismatchError -import org.jetbrains.kotlin.fir.resolve.diagnostics.FirVariableExpectedError +import org.jetbrains.kotlin.fir.resolve.diagnostics.* import org.jetbrains.kotlin.fir.resolve.transformers.InvocationKindTransformer import org.jetbrains.kotlin.fir.resolve.transformers.StoreReceiver import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType @@ -630,6 +628,63 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : } } + @OptIn(ExperimentalStdlibApi::class) + override fun transformArraySetCall(arraySetCall: FirArraySetCall, data: ResolutionMode): CompositeTransformResult { + assert(arraySetCall.operation in FirOperation.ASSIGNMENTS) + assert(arraySetCall.operation != FirOperation.ASSIGN) + + val operatorName = FirOperationNameConventions.ASSIGNMENTS.getValue(arraySetCall.operation) + + val firstCalls = with(arraySetCall.setGetBlock.statements.last() as FirFunctionCall) setCall@{ + buildList { + add(this@setCall) + with(arguments.last() as FirFunctionCall) plusCall@{ + add(this@plusCall) + add(explicitReceiver as FirFunctionCall) + } + } + } + val secondCalls = listOf( + arraySetCall.assignCall, + arraySetCall.assignCall.explicitReceiver as FirFunctionCall + ) + + val firstResult = withLocalScopeCleanup { + arraySetCall.setGetBlock.transformSingle(transformer, ResolutionMode.ContextIndependent) + } + val secondResult = arraySetCall.assignCall.transformSingle(transformer, ResolutionMode.ContextIndependent) + + val firstSucceed = firstCalls.all { it.typeRef !is FirErrorTypeRef } + val secondSucceed = secondCalls.all { it.typeRef !is FirErrorTypeRef } + + val result: FirStatement = when { + firstSucceed && secondSucceed -> { + arraySetCall.also { + it.replaceCalleeReference( + buildErrorNamedReference { + // TODO: add better diagnostic + source = arraySetCall.source + diagnostic = FirAmbiguityError(operatorName, emptyList()) + } + ) + } + } + firstSucceed -> firstResult + secondSucceed -> secondResult + else -> { + arraySetCall.also { + it.replaceCalleeReference( + buildErrorNamedReference { + source = arraySetCall.source + diagnostic = FirUnresolvedNameError(operatorName) + } + ) + } + } + } + return result.compose() + } + // ------------------------------------------------------------------------------------------------ internal fun storeTypeFromCallee(access: T) where T : FirQualifiedAccess, T : FirExpression { diff --git a/compiler/fir/resolve/testData/resolve/arrays/arraySet.kt b/compiler/fir/resolve/testData/resolve/arrays/arraySet.kt new file mode 100644 index 00000000000..ed31f6b10c4 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/arrays/arraySet.kt @@ -0,0 +1,31 @@ +// ISSUE: KT-37516 + +class A { + operator fun get(index: Int): T = null!! + operator fun set(index: Int, value: T) {} +} + +class B { + operator fun plusAssign(other: B) {} +} + +class C { + operator fun plus(other: C): C = this +} + +class D { + operator fun plusAssign(other: D) {} + operator fun plus(other: D): D = this +} + +fun test_1(a: A) { + a[0] = B() // set +} + +fun test_2(a: A) { + a[0] = C() // set +} + +fun test_3(a: A) { + a[0] = D() // set +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/arrays/arraySet.txt b/compiler/fir/resolve/testData/resolve/arrays/arraySet.txt new file mode 100644 index 00000000000..cdfb6761a7b --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/arrays/arraySet.txt @@ -0,0 +1,55 @@ +FILE: arraySet.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public final operator fun get(index: R|kotlin/Int|): R|T| { + ^get Null(null)!! + } + + public final operator fun set(index: R|kotlin/Int|, value: R|T|): R|kotlin/Unit| { + } + + } + public final class B : R|kotlin/Any| { + public constructor(): R|B| { + super() + } + + public final operator fun plusAssign(other: R|B|): R|kotlin/Unit| { + } + + } + public final class C : R|kotlin/Any| { + public constructor(): R|C| { + super() + } + + public final operator fun plus(other: R|C|): R|C| { + ^plus this@R|/C| + } + + } + public final class D : R|kotlin/Any| { + public constructor(): R|D| { + super() + } + + public final operator fun plusAssign(other: R|D|): R|kotlin/Unit| { + } + + public final operator fun plus(other: R|D|): R|D| { + ^plus this@R|/D| + } + + } + public final fun test_1(a: R|A|): R|kotlin/Unit| { + R|/a|.R|FakeOverride|(Int(0), R|/B.B|()) + } + public final fun test_2(a: R|A|): R|kotlin/Unit| { + R|/a|.R|FakeOverride|(Int(0), R|/C.C|()) + } + public final fun test_3(a: R|A|): R|kotlin/Unit| { + R|/a|.R|FakeOverride|(Int(0), R|/D.D|()) + } diff --git a/compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.kt b/compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.kt new file mode 100644 index 00000000000..3a96512472a --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.kt @@ -0,0 +1,36 @@ +// ISSUE: KT-37516 + +class A { + operator fun get(index: Int): T = null!! + operator fun set(index: Int, value: T) {} +} + +class B { + operator fun plusAssign(other: B) {} +} + +class C { + operator fun plus(other: C): C = this +} + +class D { + operator fun plusAssign(other: D) {} + operator fun plus(other: D): D = this +} + +fun test_1(a: A) { +// foo().bar()[0] += x + a[0] += B() // get, plusAssign +} + +fun test_2(a: A) { + a[0] += C() // get, set, plus +} + +fun test_3(a: A) { + a[0] += D() // ambiguity +} + +fun test_4(b: B) { + b[0] += B() // unresolved +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.txt b/compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.txt new file mode 100644 index 00000000000..12e34b5f38f --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.txt @@ -0,0 +1,63 @@ +FILE: arraySetWithOperation.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public final operator fun get(index: R|kotlin/Int|): R|T| { + ^get Null(null)!! + } + + public final operator fun set(index: R|kotlin/Int|, value: R|T|): R|kotlin/Unit| { + } + + } + public final class B : R|kotlin/Any| { + public constructor(): R|B| { + super() + } + + public final operator fun plusAssign(other: R|B|): R|kotlin/Unit| { + } + + } + public final class C : R|kotlin/Any| { + public constructor(): R|C| { + super() + } + + public final operator fun plus(other: R|C|): R|C| { + ^plus this@R|/C| + } + + } + public final class D : R|kotlin/Any| { + public constructor(): R|D| { + super() + } + + public final operator fun plusAssign(other: R|D|): R|kotlin/Unit| { + } + + public final operator fun plus(other: R|D|): R|D| { + ^plus this@R|/D| + } + + } + public final fun test_1(a: R|A|): R|kotlin/Unit| { + R|/a|.R|FakeOverride|(Int(0)).R|/B.plusAssign|(R|/B.B|()) + } + public final fun test_2(a: R|A|): R|kotlin/Unit| { + { + lval <>: R|A| = R|/a| + lval <>: R|kotlin/Int| = Int(0) + R|/<>|.R|FakeOverride|(R|/<>|, R|/<>|.R|FakeOverride|(R|/<>|).R|/C.plus|(R|/C.C|())) + } + + } + public final fun test_3(a: R|A|): R|kotlin/Unit| { + ArraySet:[R|/a|.R|FakeOverride|(Int(0)).R|/D.plusAssign|(R|/D.D|())] + } + public final fun test_4(b: R|B|): R|kotlin/Unit| { + ArraySet:[R|/b|.#(Int(0)).#(R|/B.B|())] + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 354bbca7202..4bda2109717 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -526,6 +526,29 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { } } + @TestMetadata("compiler/fir/resolve/testData/resolve/arrays") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Arrays extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInArrays() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/arrays"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("arraySet.kt") + public void testArraySet() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/arrays/arraySet.kt"); + } + + @TestMetadata("arraySetWithOperation.kt") + public void testArraySetWithOperation() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.kt"); + } + } + @TestMetadata("compiler/fir/resolve/testData/resolve/builtins") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 8f365f8e410..4f1a5ddb5e9 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -526,6 +526,29 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos } } + @TestMetadata("compiler/fir/resolve/testData/resolve/arrays") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Arrays extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInArrays() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/arrays"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("arraySet.kt") + public void testArraySet() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/arrays/arraySet.kt"); + } + + @TestMetadata("arraySetWithOperation.kt") + public void testArraySetWithOperation() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/arrays/arraySetWithOperation.kt"); + } + } + @TestMetadata("compiler/fir/resolve/testData/resolve/builtins") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArraySetCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArraySetCall.kt index 4a2ccd99216..2535debfdff 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArraySetCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArraySetCall.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.expressions import org.jetbrains.kotlin.fir.FirPureAbstractElement import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.references.FirReference -import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.visitors.* /* @@ -16,34 +15,15 @@ import org.jetbrains.kotlin.fir.visitors.* * DO NOT MODIFY IT MANUALLY */ -abstract class FirArraySetCall : FirPureAbstractElement(), FirQualifiedAccess, FirCall { +abstract class FirArraySetCall : FirPureAbstractElement(), FirStatement { abstract override val source: FirSourceElement? abstract override val annotations: List - abstract override val safe: Boolean - abstract override val typeArguments: List - abstract override val explicitReceiver: FirExpression? - abstract override val dispatchReceiver: FirExpression - abstract override val extensionReceiver: FirExpression - abstract override val calleeReference: FirReference - abstract override val argumentList: FirArgumentList - abstract val rValue: FirExpression + abstract val assignCall: FirFunctionCall + abstract val setGetBlock: FirBlock abstract val operation: FirOperation - abstract val lValue: FirReference - abstract val indexes: List + abstract val calleeReference: FirReference override fun accept(visitor: FirVisitor, data: D): R = visitor.visitArraySetCall(this, data) - abstract override fun transformTypeArguments(transformer: FirTransformer, data: D): FirArraySetCall - - abstract override fun transformExplicitReceiver(transformer: FirTransformer, data: D): FirArraySetCall - - abstract override fun transformDispatchReceiver(transformer: FirTransformer, data: D): FirArraySetCall - - abstract override fun transformExtensionReceiver(transformer: FirTransformer, data: D): FirArraySetCall - - abstract override fun transformCalleeReference(transformer: FirTransformer, data: D): FirArraySetCall - - abstract fun transformRValue(transformer: FirTransformer, data: D): FirArraySetCall - - abstract fun transformIndexes(transformer: FirTransformer, data: D): FirArraySetCall + abstract fun replaceCalleeReference(newCalleeReference: FirReference) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArraySetCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArraySetCallBuilder.kt index 898b6d7f0da..2e7d5c81449 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArraySetCallBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirArraySetCallBuilder.kt @@ -10,16 +10,13 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.expressions.FirArgumentList import org.jetbrains.kotlin.fir.expressions.FirArraySetCall -import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirOperation -import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessBuilder import org.jetbrains.kotlin.fir.expressions.impl.FirArraySetCallImpl -import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess -import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.references.FirReference -import org.jetbrains.kotlin.fir.types.FirTypeProjection +import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.visitors.* /* @@ -28,34 +25,22 @@ import org.jetbrains.kotlin.fir.visitors.* */ @FirBuilderDsl -class FirArraySetCallBuilder : FirQualifiedAccessBuilder, FirAnnotationContainerBuilder { +class FirArraySetCallBuilder : FirAnnotationContainerBuilder { override var source: FirSourceElement? = null override val annotations: MutableList = mutableListOf() - override var safe: Boolean = false - override val typeArguments: MutableList = mutableListOf() - override var explicitReceiver: FirExpression? = null - override var dispatchReceiver: FirExpression = FirNoReceiverExpression - override var extensionReceiver: FirExpression = FirNoReceiverExpression - lateinit var calleeReference: FirReference - lateinit var argumentList: FirArgumentList - lateinit var rValue: FirExpression + lateinit var assignCall: FirFunctionCall + lateinit var setGetBlock: FirBlock lateinit var operation: FirOperation - val indexes: MutableList = mutableListOf() + var calleeReference: FirReference = FirStubReference override fun build(): FirArraySetCall { return FirArraySetCallImpl( source, annotations, - safe, - typeArguments, - explicitReceiver, - dispatchReceiver, - extensionReceiver, - calleeReference, - argumentList, - rValue, + assignCall, + setGetBlock, operation, - indexes, + calleeReference, ) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetCallImpl.kt index c59bb3186a7..03bdd46a179 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetCallImpl.kt @@ -7,13 +7,11 @@ package org.jetbrains.kotlin.fir.expressions.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.expressions.FirArgumentList import org.jetbrains.kotlin.fir.expressions.FirArraySetCall -import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirOperation -import org.jetbrains.kotlin.fir.expressions.impl.FirModifiableQualifiedAccess import org.jetbrains.kotlin.fir.references.FirReference -import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.visitors.* /* @@ -24,97 +22,27 @@ import org.jetbrains.kotlin.fir.visitors.* internal class FirArraySetCallImpl( override val source: FirSourceElement?, override val annotations: MutableList, - override var safe: Boolean, - override val typeArguments: MutableList, - override var explicitReceiver: FirExpression?, - override var dispatchReceiver: FirExpression, - override var extensionReceiver: FirExpression, - override var calleeReference: FirReference, - override var argumentList: FirArgumentList, - override var rValue: FirExpression, + override var assignCall: FirFunctionCall, + override var setGetBlock: FirBlock, override val operation: FirOperation, - override val indexes: MutableList, -) : FirArraySetCall(), FirModifiableQualifiedAccess { - override var lValue: FirReference - get() = calleeReference - set(value) { - calleeReference = value - } - + override var calleeReference: FirReference, +) : FirArraySetCall() { override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } - typeArguments.forEach { it.accept(visitor, data) } - explicitReceiver?.accept(visitor, data) - if (dispatchReceiver !== explicitReceiver) { - dispatchReceiver.accept(visitor, data) - } - if (extensionReceiver !== explicitReceiver && extensionReceiver !== dispatchReceiver) { - extensionReceiver.accept(visitor, data) - } + assignCall.accept(visitor, data) + setGetBlock.accept(visitor, data) calleeReference.accept(visitor, data) - argumentList.accept(visitor, data) - rValue.accept(visitor, data) - indexes.forEach { it.accept(visitor, data) } } override fun transformChildren(transformer: FirTransformer, data: D): FirArraySetCallImpl { annotations.transformInplace(transformer, data) - transformTypeArguments(transformer, data) - explicitReceiver = explicitReceiver?.transformSingle(transformer, data) - if (dispatchReceiver !== explicitReceiver) { - dispatchReceiver = dispatchReceiver.transformSingle(transformer, data) - } - if (extensionReceiver !== explicitReceiver && extensionReceiver !== dispatchReceiver) { - extensionReceiver = extensionReceiver.transformSingle(transformer, data) - } - transformCalleeReference(transformer, data) - argumentList = argumentList.transformSingle(transformer, data) - transformRValue(transformer, data) - transformIndexes(transformer, data) - return this - } - - override fun transformTypeArguments(transformer: FirTransformer, data: D): FirArraySetCallImpl { - typeArguments.transformInplace(transformer, data) - return this - } - - override fun transformExplicitReceiver(transformer: FirTransformer, data: D): FirArraySetCallImpl { - explicitReceiver = explicitReceiver?.transformSingle(transformer, data) - return this - } - - override fun transformDispatchReceiver(transformer: FirTransformer, data: D): FirArraySetCallImpl { - dispatchReceiver = dispatchReceiver.transformSingle(transformer, data) - return this - } - - override fun transformExtensionReceiver(transformer: FirTransformer, data: D): FirArraySetCallImpl { - extensionReceiver = extensionReceiver.transformSingle(transformer, data) - return this - } - - override fun transformCalleeReference(transformer: FirTransformer, data: D): FirArraySetCallImpl { + assignCall = assignCall.transformSingle(transformer, data) + setGetBlock = setGetBlock.transformSingle(transformer, data) calleeReference = calleeReference.transformSingle(transformer, data) return this } - override fun transformRValue(transformer: FirTransformer, data: D): FirArraySetCallImpl { - rValue = rValue.transformSingle(transformer, data) - return this - } - - override fun transformIndexes(transformer: FirTransformer, data: D): FirArraySetCallImpl { - indexes.transformInplace(transformer, data) - return this - } - - override fun replaceTypeArguments(newTypeArguments: List) { - typeArguments.clear() - typeArguments.addAll(newTypeArguments) - } - - override fun replaceArgumentList(newArgumentList: FirArgumentList) { - argumentList = newArgumentList + override fun replaceCalleeReference(newCalleeReference: FirReference) { + calleeReference = newCalleeReference } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 81bd3f9aa1f..fd3060d8c02 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -25,7 +25,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.types.Variance @@ -1000,12 +999,9 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM override fun visitArraySetCall(arraySetCall: FirArraySetCall) { arraySetCall.annotations.renderAnnotations() - visitQualifiedAccess(arraySetCall) - arraySetCall.lValue.accept(this) - print("[") - arraySetCall.indexes.renderSeparated() - print("] ") - visitAssignment(arraySetCall.operation, arraySetCall.rValue) + print("ArraySet:[") + arraySetCall.assignCall.accept(this) + print("]") } override fun visitFunctionCall(functionCall: FirFunctionCall) { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt index b1ea026207f..d96e4762b79 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt @@ -112,9 +112,8 @@ object BuilderConfigurator : AbstractBuilderConfigurator(FirTree } builder(arraySetCall) { - parents += qualifiedAccessBuilder - defaultFalse("safe") - defaultNoReceivers() + default("calleeReference", "FirStubReference") + useTypes(stubReferenceType) } builder(callableReferenceAccess) { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt index c74359bda8c..b4656e9bdbb 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt @@ -89,7 +89,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() { val checkNotNullCall = element("CheckNotNullCall", Expression, expression, call, resolvable) val arrayOfCall = element("ArrayOfCall", Expression, expression, call) - val arraySetCall = element("ArraySetCall", Expression, qualifiedAccess, call) + val arraySetCall = element("ArraySetCall", Expression, statement) val classReferenceExpression = element("ClassReferenceExpression", Expression, expression) val errorExpression = element("ErrorExpression", Expression, expression, diagnosticHolder) val errorFunction = element("ErrorFunction", Declaration, function, diagnosticHolder) diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index fa62cacac3c..dc447d8fffa 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -86,14 +86,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() isMutable("safe") } - impl(arraySetCall) { - parents += modifiableQualifiedAccess - default("lValue") { - value = "calleeReference" - customSetter = "calleeReference = value" - } - } - impl(callableReferenceAccess) { parents += modifiableQualifiedAccess } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index b3793278457..b22e06e88db 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -396,10 +396,10 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild } arraySetCall.configure { - +field("rValue", expression).withTransform() + +field("assignCall", functionCall) + +field("setGetBlock", block) +field("operation", operationType) - +field("lValue", reference) - +fieldList("indexes", expression).withTransform() + +field("calleeReference", reference, withReplace = true) } classReferenceExpression.configure { diff --git a/compiler/testData/codegen/box/arrays/arrayPlusAssign.kt b/compiler/testData/codegen/box/arrays/arrayPlusAssign.kt index 358233bbe15..9a243990fd5 100644 --- a/compiler/testData/codegen/box/arrays/arrayPlusAssign.kt +++ b/compiler/testData/codegen/box/arrays/arrayPlusAssign.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun box(): String { val s = IntArray(1) s[0] = 5 diff --git a/compiler/testData/codegen/box/arrays/collectionAssignGetMultiIndex.kt b/compiler/testData/codegen/box/arrays/collectionAssignGetMultiIndex.kt index 44d80d6859d..4a7d83c589e 100644 --- a/compiler/testData/codegen/box/arrays/collectionAssignGetMultiIndex.kt +++ b/compiler/testData/codegen/box/arrays/collectionAssignGetMultiIndex.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME operator fun ArrayList.get(index1: Int, index2: Int) = this[index1 + index2] operator fun ArrayList.set(index1: Int, index2: Int, elem: String) { diff --git a/compiler/testData/codegen/box/arrays/kt33.kt b/compiler/testData/codegen/box/arrays/kt33.kt index 8d023e240c2..f705364a5a2 100644 --- a/compiler/testData/codegen/box/arrays/kt33.kt +++ b/compiler/testData/codegen/box/arrays/kt33.kt @@ -1,4 +1,4 @@ -// IGNORE_BACKEND_FIR: JVM_IR + // KJS_WITH_FULL_RUNTIME fun box () : String { val s = ArrayList() diff --git a/compiler/testData/codegen/box/arrays/longAsIndex.kt b/compiler/testData/codegen/box/arrays/longAsIndex.kt index ceac633d4c8..c12d4dca9a4 100644 --- a/compiler/testData/codegen/box/arrays/longAsIndex.kt +++ b/compiler/testData/codegen/box/arrays/longAsIndex.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR operator fun IntArray.set(index: Long, elem: Int) { this[index.toInt()] = elem } operator fun IntArray.get(index: Long) = this[index.toInt()] diff --git a/compiler/testData/codegen/box/arrays/multiDecl/kt15560.kt b/compiler/testData/codegen/box/arrays/multiDecl/kt15560.kt index d6c473f31b4..552a6653a97 100644 --- a/compiler/testData/codegen/box/arrays/multiDecl/kt15560.kt +++ b/compiler/testData/codegen/box/arrays/multiDecl/kt15560.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun box(): String { val array = arrayOf(doubleArrayOf(-1.0)) for (node in array) { diff --git a/compiler/testData/codegen/box/classes/kt508.kt b/compiler/testData/codegen/box/classes/kt508.kt index e0ed5e638eb..2f985304586 100644 --- a/compiler/testData/codegen/box/classes/kt508.kt +++ b/compiler/testData/codegen/box/classes/kt508.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME operator fun MutableMap.set(key : K, value : V) = put(key, value) diff --git a/compiler/testData/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIndexedCAO.kt b/compiler/testData/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIndexedCAO.kt index 11d2983d00f..44e0531c7b7 100644 --- a/compiler/testData/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIndexedCAO.kt +++ b/compiler/testData/codegen/box/closures/capturedVarsOptimization/capturedInInlineOnlyIndexedCAO.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME class Host(var value: String) { diff --git a/compiler/testData/codegen/box/defaultArguments/convention/plusAssignWithDefaultInGetter.kt b/compiler/testData/codegen/box/defaultArguments/convention/plusAssignWithDefaultInGetter.kt index 1f5f0ed39e2..0b6f63450de 100644 --- a/compiler/testData/codegen/box/defaultArguments/convention/plusAssignWithDefaultInGetter.kt +++ b/compiler/testData/codegen/box/defaultArguments/convention/plusAssignWithDefaultInGetter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class X { var result: String = "fail" diff --git a/compiler/testData/codegen/box/objects/compoundAssignmentToArrayAccessToPropertyImportedFromObject.kt b/compiler/testData/codegen/box/objects/compoundAssignmentToArrayAccessToPropertyImportedFromObject.kt index 7204d2883bc..bfe33afdeaa 100644 --- a/compiler/testData/codegen/box/objects/compoundAssignmentToArrayAccessToPropertyImportedFromObject.kt +++ b/compiler/testData/codegen/box/objects/compoundAssignmentToArrayAccessToPropertyImportedFromObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME import Host.x diff --git a/compiler/testData/codegen/box/operatorConventions/overloadedSet.kt b/compiler/testData/codegen/box/operatorConventions/overloadedSet.kt index a468bdf5980..839722da16a 100644 --- a/compiler/testData/codegen/box/operatorConventions/overloadedSet.kt +++ b/compiler/testData/codegen/box/operatorConventions/overloadedSet.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR object A { operator fun get(i: Int) = 1 operator fun set(i: Int, j: Int) {} diff --git a/compiler/testData/codegen/box/platformTypes/primitives/plusAssign.kt b/compiler/testData/codegen/box/platformTypes/primitives/plusAssign.kt index 647f2ad6e80..80884149fc9 100644 --- a/compiler/testData/codegen/box/platformTypes/primitives/plusAssign.kt +++ b/compiler/testData/codegen/box/platformTypes/primitives/plusAssign.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME fun box(): String { val l = ArrayList() diff --git a/compiler/testData/codegen/box/private/arrayConvention.kt b/compiler/testData/codegen/box/private/arrayConvention.kt index a23aaf930b9..5d778552e83 100644 --- a/compiler/testData/codegen/box/private/arrayConvention.kt +++ b/compiler/testData/codegen/box/private/arrayConvention.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR var result = "fail" private operator fun X.get(name: String) = name + "K" diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/InconsistentGetSet.fir.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/InconsistentGetSet.fir.kt index acb1654a31f..03d70dfc9c3 100644 --- a/compiler/testData/diagnostics/tests/operatorsOverloading/InconsistentGetSet.fir.kt +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/InconsistentGetSet.fir.kt @@ -20,7 +20,7 @@ object MismatchingTypes { fun testMismatchingTypes() { ++MismatchingTypes[0] MismatchingTypes[0]++ - MismatchingTypes[0] += 1 + MismatchingTypes[0] += 1 } object MismatchingArities1 { @@ -36,10 +36,10 @@ object MismatchingArities2 { fun testMismatchingArities() { ++MismatchingArities1[0] MismatchingArities1[0]++ - MismatchingArities1[0] += 1 + MismatchingArities1[0] += 1 ++MismatchingArities2[0] MismatchingArities2[0]++ - MismatchingArities2[0] += 1 + MismatchingArities2[0] += 1 } diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnArray.fir.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnArray.fir.kt index 532bba2f335..bf4edbd5427 100644 --- a/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnArray.fir.kt +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/plusAssignOnArray.fir.kt @@ -16,5 +16,5 @@ fun test() { val c = C() c[0] += "" var c1 = C1() - c1[0] += "" + c1[0] += "" } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt10633.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt10633.fir.kt index 0b14f8f5049..43971cfe338 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt10633.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt10633.fir.kt @@ -13,7 +13,7 @@ operator fun Int.set(s: Int, x: String = "", z: Int) { fun main() { 1[2] = 1 1.set(2, z = 1) - 1[2] += 1 + 1[2] += 1 1.set(2, 1) } diff --git a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.fir.txt b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.fir.txt index f0f68041d02..6921edada75 100644 --- a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.fir.txt +++ b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.fir.txt @@ -46,16 +46,38 @@ FILE fqName: fileName:/arrayAugmentedAssignment1.kt BLOCK_BODY VAR name:x type:kotlin.IntArray [var] CALL 'public final fun foo (): kotlin.IntArray declared in ' type=kotlin.IntArray origin=null - ERROR_CALL 'FirArraySetCall (resolve isn't supported yet)' type=kotlin.Unit + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.IntArray [val] + GET_VAR 'var x: kotlin.IntArray [var] declared in .testVariable' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit [operator] declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val tmp_0: kotlin.IntArray [val] declared in .testVariable' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_1: kotlin.Int [val] declared in .testVariable' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in kotlin.IntArray' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_0: kotlin.IntArray [val] declared in .testVariable' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_1: kotlin.Int [val] declared in .testVariable' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=1 FUN name:testCall visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.IntArray [val] - CALL 'public final fun foo (): kotlin.IntArray declared in ' type=kotlin.IntArray origin=null - ERROR_CALL 'FirArraySetCall (resolve isn't supported yet)' type=kotlin.Unit + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.IntArray [val] + CALL 'public final fun foo (): kotlin.IntArray declared in ' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + CALL 'public final fun bar (): kotlin.Int declared in ' type=kotlin.Int origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit [operator] declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val tmp_2: kotlin.IntArray [val] declared in .testCall' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_3: kotlin.Int [val] declared in .testCall' type=kotlin.Int origin=null + value: CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in kotlin.IntArray' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_2: kotlin.IntArray [val] declared in .testCall' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_3: kotlin.Int [val] declared in .testCall' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=2 FUN name:testMember visibility:public modality:FINAL <> (c:.C) returnType:kotlin.Unit VALUE_PARAMETER name:c index:0 type:.C BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val] CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in kotlin.IntArray' type=kotlin.Int origin=null $this: CALL 'public final fun (): kotlin.IntArray declared in .C' type=kotlin.IntArray origin=GET_PROPERTY $this: GET_VAR 'c: .C declared in .testMember' type=.C origin=null @@ -65,5 +87,5 @@ FILE fqName: fileName:/arrayAugmentedAssignment1.kt $this: GET_VAR 'c: .C declared in .testMember' type=.C origin=null index: CONST Int type=kotlin.Int value=0 value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_1: kotlin.Int [val] declared in .testMember' type=kotlin.Int origin=null - GET_VAR 'val tmp_1: kotlin.Int [val] declared in .testMember' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_4: kotlin.Int [val] declared in .testMember' type=kotlin.Int origin=null + GET_VAR 'val tmp_4: kotlin.Int [val] declared in .testMember' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment2.fir.txt b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment2.fir.txt index 930854f18a7..68194b85141 100644 --- a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment2.fir.txt +++ b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment2.fir.txt @@ -41,4 +41,17 @@ FILE fqName: fileName:/arrayAugmentedAssignment2.kt $receiver: VALUE_PARAMETER name: type:.IB VALUE_PARAMETER name:a index:0 type:.IA BLOCK_BODY - ERROR_CALL 'FirArraySetCall (resolve isn't supported yet)' type=kotlin.Unit + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.IA [val] + GET_VAR 'a: .IA declared in .test' type=.IA origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.String [val] + CONST String type=kotlin.String value="" + CALL 'public abstract fun set (index: kotlin.String, value: kotlin.Int): kotlin.Unit [operator] declared in .IB' type=kotlin.Unit origin=null + $this: GET_VAR ': .IB declared in .test' type=.IB origin=null + $receiver: GET_VAR 'val tmp_0: .IA [val] declared in .test' type=.IA origin=null + index: GET_VAR 'val tmp_1: kotlin.String [val] declared in .test' type=kotlin.String origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public abstract fun get (index: kotlin.String): kotlin.Int [operator] declared in .IA' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_0: .IA [val] declared in .test' type=.IA origin=null + index: GET_VAR 'val tmp_1: kotlin.String [val] declared in .test' type=kotlin.String origin=null + other: CONST Int type=kotlin.Int value=42 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt index e19a38af3a4..56e08be7e7b 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt @@ -111,7 +111,19 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt FUN name:test3 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 BLOCK_BODY - ERROR_CALL 'FirArraySetCall (resolve isn't supported yet)' type=kotlin.Unit + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.A [val] + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Function1 [val] + GET_VAR 'fn: kotlin.Function1 declared in .test3' type=kotlin.Function1 origin=null + CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_0: .A [val] declared in .test3' type=.A origin=null + i: GET_VAR 'val tmp_1: kotlin.Function1 [val] declared in .test3' type=kotlin.Function1 origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_0: .A [val] declared in .test3' type=.A origin=null + i: GET_VAR 'val tmp_1: kotlin.Function1 [val] declared in .test3' type=kotlin.Function1 origin=null + other: CONST Int type=kotlin.Int value=1 FUN name:test4 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 BLOCK_BODY @@ -120,13 +132,40 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.IFoo GET_VAR 'fn: kotlin.Function1 declared in .test4' type=kotlin.Function1 origin=null then: BLOCK type=kotlin.Unit origin=null - ERROR_CALL 'FirArraySetCall (resolve isn't supported yet)' type=kotlin.Unit + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.A [val] + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:.IFoo [val] + TYPE_OP type=.IFoo origin=IMPLICIT_CAST typeOperand=.IFoo + GET_VAR 'fn: kotlin.Function1 declared in .test4' type=kotlin.Function1 origin=null + CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_2: .A [val] declared in .test4' type=.A origin=null + i: TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_3: .IFoo [val] declared in .test4' type=.IFoo origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_2: .A [val] declared in .test4' type=.A origin=null + i: TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_3: .IFoo [val] declared in .test4' type=.IFoo origin=null + other: CONST Int type=kotlin.Int value=1 FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY TYPE_OP type=kotlin.Function1 origin=CAST typeOperand=kotlin.Function1 GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null - ERROR_CALL 'FirArraySetCall (resolve isn't supported yet)' type=kotlin.Unit + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:.A [val] + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Function1 [val] + TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null + CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_4: .A [val] declared in .test5' type=.A origin=null + i: GET_VAR 'val tmp_5: kotlin.Function1 [val] declared in .test5' type=kotlin.Function1 origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_4: .A [val] declared in .test5' type=.A origin=null + i: GET_VAR 'val tmp_5: kotlin.Function1 [val] declared in .test5' type=kotlin.Function1 origin=null + other: CONST Int type=kotlin.Int value=1 FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY @@ -135,4 +174,17 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt TYPE_OP type=.IFoo origin=CAST typeOperand=.IFoo TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 GET_VAR 'a: kotlin.Any declared in .test6' type=kotlin.Any origin=null - ERROR_CALL 'FirArraySetCall (resolve isn't supported yet)' type=kotlin.Unit + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:.A [val] + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Function1 [val] + TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'a: kotlin.Any declared in .test6' type=kotlin.Any origin=null + CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_6: .A [val] declared in .test6' type=.A origin=null + i: GET_VAR 'val tmp_7: kotlin.Function1 [val] declared in .test6' type=kotlin.Function1 origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_6: .A [val] declared in .test6' type=.A origin=null + i: GET_VAR 'val tmp_7: kotlin.Function1 [val] declared in .test6' type=kotlin.Function1 origin=null + other: CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/expressions/kt28456.fir.txt b/compiler/testData/ir/irText/expressions/kt28456.fir.txt index 25bcce795e7..5a7610de446 100644 --- a/compiler/testData/ir/irText/expressions/kt28456.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt28456.fir.txt @@ -59,4 +59,21 @@ FILE fqName: fileName:/kt28456.kt FUN name:testCompoundAssignment visibility:public modality:FINAL <> (a:.A) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.A BLOCK_BODY - ERROR_CALL 'FirArraySetCall (resolve isn't supported yet)' type=kotlin.Unit + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.A [val] + GET_VAR 'a: .A declared in .testCompoundAssignment' type=.A origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=1 + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=2 + CALL 'public final fun set (i: kotlin.Int, j: kotlin.Int, v: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_1: .A [val] declared in .testCompoundAssignment' type=.A origin=null + i: GET_VAR 'val tmp_2: kotlin.Int [val] declared in .testCompoundAssignment' type=kotlin.Int origin=null + j: GET_VAR 'val tmp_3: kotlin.Int [val] declared in .testCompoundAssignment' type=kotlin.Int origin=null + v: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (vararg xs: kotlin.Int): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_1: .A [val] declared in .testCompoundAssignment' type=.A origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'val tmp_2: kotlin.Int [val] declared in .testCompoundAssignment' type=kotlin.Int origin=null + GET_VAR 'val tmp_3: kotlin.Int [val] declared in .testCompoundAssignment' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=10 diff --git a/compiler/testData/ir/irText/expressions/lambdaInCAO.fir.txt b/compiler/testData/ir/irText/expressions/lambdaInCAO.fir.txt index c2b54ffc79c..cbb6e0477b5 100644 --- a/compiler/testData/ir/irText/expressions/lambdaInCAO.fir.txt +++ b/compiler/testData/ir/irText/expressions/lambdaInCAO.fir.txt @@ -26,11 +26,26 @@ FILE fqName: fileName:/lambdaInCAO.kt FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY - ERROR_CALL 'FirArraySetCall (resolve isn't supported yet)' type=kotlin.Unit + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any [val] + GET_VAR 'a: kotlin.Any declared in .test2' type=kotlin.Any origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Function0 [val] + FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit + CALL 'public final fun set (index: kotlin.Function0, value: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_0: kotlin.Any [val] declared in .test2' type=kotlin.Any origin=null + index: GET_VAR 'val tmp_1: kotlin.Function0 [val] declared in .test2' type=kotlin.Function0 origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (index: kotlin.Function0): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_0: kotlin.Any [val] declared in .test2' type=kotlin.Any origin=null + index: GET_VAR 'val tmp_1: kotlin.Function0 [val] declared in .test2' type=kotlin.Function0 origin=null + other: CONST Int type=kotlin.Int value=42 FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] CALL 'public final fun get (index: kotlin.Function0): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'a: kotlin.Any declared in .test3' type=kotlin.Any origin=null index: FUN_EXPR type=kotlin.Function0 origin=LAMBDA @@ -44,5 +59,5 @@ FILE fqName: fileName:/lambdaInCAO.kt BLOCK_BODY GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_0: kotlin.Int [val] declared in .test3' type=kotlin.Int origin=null - GET_VAR 'val tmp_0: kotlin.Int [val] declared in .test3' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_2: kotlin.Int [val] declared in .test3' type=kotlin.Int origin=null + GET_VAR 'val tmp_2: kotlin.Int [val] declared in .test3' type=kotlin.Int origin=null