diff --git a/analysis/low-level-api-fir/testdata/onAirResolve/loopConstruction.txt b/analysis/low-level-api-fir/testdata/onAirResolve/loopConstruction.txt index 3efcdb03784..c27b13815f2 100644 --- a/analysis/low-level-api-fir/testdata/onAirResolve/loopConstruction.txt +++ b/analysis/low-level-api-fir/testdata/onAirResolve/loopConstruction.txt @@ -1,6 +1,9 @@ while(CMP(<, R|/x|.R|kotlin/Int.compareTo|(Int(2)))) { - [BODY_RESOLVE] lval : R|kotlin/Int| = R|/x| - R|/x| = R|/|.R|kotlin/Int.dec|() - R|/| + { + [BODY_RESOLVE] lval : R|kotlin/Int| = R|/x| + R|/x| = R|/|.R|kotlin/Int.dec|() + R|/| + } + [BODY_RESOLVE] lval z: R|kotlin/Int| = R|/y| } diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 0282d88b01f..9cd7e85a774 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -357,6 +357,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/IncorrectCharacterLiterals.kt"); } + @Test + @TestMetadata("incrementDecrementOnFullyQualified.kt") + public void testIncrementDecrementOnFullyQualified() throws Exception { + runTest("compiler/testData/diagnostics/tests/incrementDecrementOnFullyQualified.kt"); + } + + @Test + @TestMetadata("incrementDecrementOnObject.kt") + public void testIncrementDecrementOnObject() throws Exception { + runTest("compiler/testData/diagnostics/tests/incrementDecrementOnObject.kt"); + } + @Test @TestMetadata("InferNullabilityInThenBlock.kt") public void testInferNullabilityInThenBlock() throws Exception { diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/CanBeValChecker.fir.txt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/CanBeValChecker.fir.txt index 1b6868e6089..a8e21a4b376 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/CanBeValChecker.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/CanBeValChecker.fir.txt @@ -81,9 +81,12 @@ FILE: CanBeValChecker.kt when () { R|/flag| -> { while(CMP(>, R|/a|.R|kotlin/Int.compareTo|(Int(0)))) { - lval : R|kotlin/Int| = R|/a| - R|/a| = R|/|.R|kotlin/Int.dec|() - R|/| + { + lval : R|kotlin/Int| = R|/a| + R|/a| = R|/|.R|kotlin/Int.dec|() + R|/| + } + } } @@ -111,17 +114,23 @@ FILE: CanBeValChecker.kt lvar v2: R|kotlin/Int| = Int(2) lvar v3: R|kotlin/Int| = Int(3) R|/v1| = Int(1) - lval : R|kotlin/Int| = R|/v2| - R|/v2| = R|/|.R|kotlin/Int.inc|() - R|/| + { + lval : R|kotlin/Int| = R|/v2| + R|/v2| = R|/|.R|kotlin/Int.inc|() + R|/| + } + R|kotlin/io/print|(R|/v3|) } public final fun test(): R|kotlin/Unit| { lvar a: R|kotlin/Int| = Int(0) while(CMP(>, R|/a|.R|kotlin/Int.compareTo|(Int(0)))) { - lval : R|kotlin/Int| = R|/a| - R|/a| = R|/|.R|kotlin/Int.inc|() - R|/| + { + lval : R|kotlin/Int| = R|/a| + R|/a| = R|/|.R|kotlin/Int.inc|() + R|/| + } + } } @@ -143,16 +152,22 @@ FILE: CanBeValChecker.kt public final fun cycles(): R|kotlin/Unit| { lvar a: R|kotlin/Int| = Int(10) while(CMP(>, R|/a|.R|kotlin/Int.compareTo|(Int(0)))) { - lval : R|kotlin/Int| = R|/a| - R|/a| = R|/|.R|kotlin/Int.dec|() - R|/| + { + lval : R|kotlin/Int| = R|/a| + R|/a| = R|/|.R|kotlin/Int.dec|() + R|/| + } + } lvar b: R|kotlin/Int| while(CMP(<, R|/a|.R|kotlin/Int.compareTo|(Int(10)))) { - lval : R|kotlin/Int| = R|/a| - R|/a| = R|/|.R|kotlin/Int.inc|() - R|/| + { + lval : R|kotlin/Int| = R|/a| + R|/a| = R|/|.R|kotlin/Int.inc|() + R|/| + } + R|/b| = R|/a| } diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 31d69a0d68c..cc63ff556f5 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -357,6 +357,18 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/IncorrectCharacterLiterals.kt"); } + @Test + @TestMetadata("incrementDecrementOnFullyQualified.kt") + public void testIncrementDecrementOnFullyQualified() throws Exception { + runTest("compiler/testData/diagnostics/tests/incrementDecrementOnFullyQualified.kt"); + } + + @Test + @TestMetadata("incrementDecrementOnObject.kt") + public void testIncrementDecrementOnObject() throws Exception { + runTest("compiler/testData/diagnostics/tests/incrementDecrementOnObject.kt"); + } + @Test @TestMetadata("InferNullabilityInThenBlock.kt") public void testInferNullabilityInThenBlock() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 5b255d19433..3fd8be24e08 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -357,6 +357,18 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/IncorrectCharacterLiterals.kt"); } + @Test + @TestMetadata("incrementDecrementOnFullyQualified.kt") + public void testIncrementDecrementOnFullyQualified() throws Exception { + runTest("compiler/testData/diagnostics/tests/incrementDecrementOnFullyQualified.kt"); + } + + @Test + @TestMetadata("incrementDecrementOnObject.kt") + public void testIncrementDecrementOnObject() throws Exception { + runTest("compiler/testData/diagnostics/tests/incrementDecrementOnObject.kt"); + } + @Test @TestMetadata("InferNullabilityInThenBlock.kt") public void testInferNullabilityInThenBlock() throws Exception { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt index bb4a1a0fe81..4237fc7bdc9 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt @@ -469,7 +469,7 @@ fun checkTypeMismatch( context ) } - source.kind is KtFakeSourceElementKind.DesugaredIncrementOrDecrement -> { + source.kind is KtFakeSourceElementKind.DesugaredIncrementOrDecrement || assignment?.source?.kind is KtFakeSourceElementKind.DesugaredIncrementOrDecrement -> { if (!lValueType.isNullable && rValueType.isNullable) { val tempType = rValueType rValueType = lValueType diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index b134ec127fc..96ee2e6ee18 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -26873,6 +26873,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -49043,12 +49049,24 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index c2206a4dd14..d3b1a1eea26 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -26873,6 +26873,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -49043,12 +49049,24 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt index 869c98ea720..38b78a0797d 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt @@ -27,9 +27,7 @@ FILE: destructuring.kt lvar x: = R|/|.component1#() lvar y: = R|/|.component2#() lvar z: String = R|/|.component3#() - lval : = x# - x# = R|/|.inc#() - R|/| + x#++ *=(y#, Double(2.0)) z# = String() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithUnaryOperators.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithUnaryOperators.txt index 389ff624dca..5e12e381a03 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithUnaryOperators.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithUnaryOperators.txt @@ -1,23 +1,8 @@ FILE: safeCallsWithUnaryOperators.kt public? final? fun foo(): R|kotlin/Unit| { - a#?.{ { - lval : = $subj$ - lval : = R|/|.b# - R|/|.b# = R|/|.inc#() - R|/| - } - } - a#?.{ $subj$.b# }?.{ { - lval : = $subj$ - lval : = R|/|.c# - R|/|.c# = R|/|.inc#() - R|/| - } - } - lval : = a#?.{ $subj$.b# } - lval : = R|/|.c# - R|/|.c# = R|/|.inc#() - R|/| + a#?.{ $subj$.b# }++ + a#?.{ $subj$.b# }?.{ $subj$.c# }++ + a#?.{ $subj$.b# }.c#++ a#?.{ { lval : = $subj$.b# lval : = IntegerLiteral(0) @@ -60,30 +45,12 @@ FILE: safeCallsWithUnaryOperators.kt lval : = R|/|.get#(R|/|) R|/|.set#(R|/|, R|/|.inc#()) R|/| - lval : = a#?.{ $subj$.b# } - lval : = R|/|.d#() - R|/|.d#() = R|/|.inc#() - R|/| + a#?.{ $subj$.b# }.d#()++ } public? final? fun foo2(): R|kotlin/Unit| { - a#?.{ { - lval : = $subj$ - lval : = R|/|.b#.inc#() - R|/|.b# = R|/| - R|/| - } - } - a#?.{ $subj$.b# }?.{ { - lval : = $subj$ - lval : = R|/|.c#.inc#() - R|/|.c# = R|/| - R|/| - } - } - lval : = a#?.{ $subj$.b# } - lval : = R|/|.c#.inc#() - R|/|.c# = R|/| - R|/| + ++a#?.{ $subj$.b# } + ++a#?.{ $subj$.b# }?.{ $subj$.c# } + ++a#?.{ $subj$.b# }.c# a#?.{ { lval : = $subj$.b# lval : = IntegerLiteral(0) @@ -126,8 +93,5 @@ FILE: safeCallsWithUnaryOperators.kt lval : = R|/|.get#(R|/|).inc#() R|/|.set#(R|/|, R|/|) R|/| - lval : = a#?.{ $subj$.b# } - lval : = R|/|.d#().inc#() - R|/|.d#() = R|/| - R|/| + ++a#?.{ $subj$.b# }.d#() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.txt index cdc728b46b9..4c3a994eb4a 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.txt @@ -1,28 +1,10 @@ FILE: unary.kt public? final? fun test(): R|kotlin/Unit| { lvar x: = IntegerLiteral(0) - lval x1: = { - lval : = x# - x# = R|/|.inc#() - R|/| - } - - lval x2: = { - x# = x#.inc#() - x# - } - - lval x3: = { - x# = x#.dec#() - x# - } - - lval x4: = { - lval : = x# - x# = R|/|.dec#() - R|/| - } - + lval x1: = x#++ + lval x2: = ++x# + lval x3: = --x# + lval x4: = x#-- when () { ==(x#, IntegerLiteral(0)).not#() -> { println#(String(000)) @@ -40,20 +22,8 @@ FILE: unary.kt } public? final? fun test2(x: X): R|kotlin/Unit| { - lval x1: = { - lval : = x# - lval : = R|/|.i# - R|/|.i# = R|/|.inc#() - R|/| - } - - lval x2: = { - lval : = x# - lval : = R|/|.i#.inc#() - R|/|.i# = R|/| - R|/| - } - + lval x1: = x#.i#++ + lval x2: = ++x#.i# } public? final? fun test3(arr: Array): R|kotlin/Unit| { lval x1: = { diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.txt index 39f991f2d67..1fbe5618c98 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.txt @@ -2,14 +2,10 @@ FILE: while.kt public? final? fun foo(limit: Int): R|kotlin/Unit| { lvar k: = IntegerLiteral(0) some@while(CMP(<, k#.compareTo#(limit#))) { - lval : = k# - k# = R|/|.inc#() - R|/| + k#++ println#(k#) while(==(k#, IntegerLiteral(13))) { - lval : = k# - k# = R|/|.inc#() - R|/| + k#++ when () { CMP(<, k#.compareTo#(limit#)) -> { break@@@[CMP(<, k#.compareTo#(limit#))] @@ -30,9 +26,7 @@ FILE: while.kt public? final? fun bar(limit: Int): R|kotlin/Unit| { lvar k: = limit# do { - lval : = k# - k# = R|/|.dec#() - R|/| + k#-- println#(k#) } while(CMP(>=, k#.compareTo#(IntegerLiteral(0)))) diff --git a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt index f22af47588a..2b02333d40a 100644 --- a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt +++ b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt @@ -510,17 +510,6 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte diagnostic = ConeSimpleDiagnostic("Inc/dec without operand", DiagnosticKind.Syntax) } - if (unwrappedReceiver.elementType == DOT_QUALIFIED_EXPRESSION || unwrappedReceiver.elementType == SAFE_ACCESS_EXPRESSION) { - return generateIncrementOrDecrementBlockForQualifiedAccess( - wholeExpression, - operationReference, - unwrappedReceiver, - callName, - prefix, - convert - ) - } - if (unwrappedReceiver.elementType == ARRAY_ACCESS_EXPRESSION) { return generateIncrementOrDecrementBlockForArrayAccess( wholeExpression, @@ -532,43 +521,13 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte ) } - return buildBlock { + return buildIncrementDecrementExpression { val baseSource = wholeExpression?.toFirSourceElement() - val desugaredSource = baseSource?.fakeElement(KtFakeSourceElementKind.DesugaredIncrementOrDecrement) - source = desugaredSource - - val convertedReceiver = unwrappedReceiver.convert() - - putIncrementOrDecrementStatements( - convertedReceiver, - operationReference, - callName, - prefix, - unwrappedReceiver.takeIf { it.elementType == REFERENCE_EXPRESSION }?.getReferencedNameAsName(), - desugaredSource, - ) { resultInitializer: FirExpression, resultVar: FirVariable -> - val assignment = unwrappedReceiver.generateAssignment( - desugaredSource, - null, - if (prefix && unwrappedReceiver.elementType != REFERENCE_EXPRESSION) - generateResolvedAccessExpression(source, resultVar) - else - resultInitializer, - FirOperation.ASSIGN, - resultInitializer.annotations, - null - ) { - // We want the DesugaredAssignmentValueReferenceExpression on the LHS to point to the same receiver instance - // as in the initializer, therefore don't create a new instance here if the argument is the receiver. - if (this == unwrappedReceiver) convertedReceiver else convert() - } - - if (assignment is FirBlock) { - statements += assignment.statements - } else { - statements += assignment - } - } + source = baseSource + operationSource = operationReference?.toFirSourceElement() + operationName = callName + isPrefix = prefix + expression = unwrappedReceiver.convert() } } @@ -672,86 +631,6 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte } } - /** - * given: - * a.b++ - * - * result: - * { - * val = a - * val = .b - * .b = .inc() - * ^ - * } - * - * given: - * ++a.b - * - * result: - * { - * val = a - * val = .b.inc() - * .b = - * ^ - * } - * - */ - @OptIn(FirContractViolation::class) - private fun generateIncrementOrDecrementBlockForQualifiedAccess( - wholeExpression: T, - operationReference: T?, - receiverForOperation: T, // a.b - callName: Name, - prefix: Boolean, - convert: T.() -> FirExpression - ): FirExpression { - return buildBlockProbablyUnderSafeCall( - receiverForOperation, - convert, - receiverForOperation.toFirSourceElement(), - ) { qualifiedFir -> - val receiverFir = (qualifiedFir as? FirQualifiedAccessExpression)?.explicitReceiver ?: buildErrorExpression { - source = receiverForOperation.toFirSourceElement() - diagnostic = ConeSimpleDiagnostic("Qualified expression without selector", DiagnosticKind.Syntax) - } - - val baseSource = wholeExpression?.toFirSourceElement() - val desugaredSource = baseSource?.fakeElement(KtFakeSourceElementKind.DesugaredIncrementOrDecrement) - source = desugaredSource - - val argumentReceiverVariable = generateTemporaryVariable( - baseModuleData, - desugaredSource, - SpecialNames.RECEIVER, - initializer = receiverFir, - ).also { statements += it } - - val receiverSource = receiverFir.source?.fakeElement(KtFakeSourceElementKind.DesugaredIncrementOrDecrement) - val firArgument = generateResolvedAccessExpression(receiverSource, argumentReceiverVariable).let { receiver -> - qualifiedFir.also { if (it is FirQualifiedAccessExpression) it.replaceExplicitReceiver(receiver) } - } - - putIncrementOrDecrementStatements( - firArgument, operationReference, callName, prefix, - nameIfSimpleReference = null, desugaredSource - ) { resultInitializer: FirExpression, resultVar: FirVariable -> - if (firArgument !is FirQualifiedAccessExpression) return@putIncrementOrDecrementStatements - statements += buildVariableAssignment { - source = desugaredSource - lValue = buildDesugaredAssignmentValueReferenceExpression { - expressionRef = FirExpressionRef().apply { bind(firArgument) } - source = firArgument.source?.fakeElement(KtFakeSourceElementKind.DesugaredIncrementOrDecrement) - } - rValue = if (prefix) { - generateResolvedAccessExpression(source, resultVar) - } else { - resultInitializer - } - } - } - } - } - /** * given: * a[b, c]++ diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirAbstractBodyResolveTransformerDispatcher.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirAbstractBodyResolveTransformerDispatcher.kt index 051209b0b2b..fa02cc10888 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirAbstractBodyResolveTransformerDispatcher.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirAbstractBodyResolveTransformerDispatcher.kt @@ -160,6 +160,13 @@ abstract class FirAbstractBodyResolveTransformerDispatcher( return expressionsTransformer.transformAssignmentOperatorStatement(assignmentOperatorStatement, data) } + override fun transformIncrementDecrementExpression( + incrementDecrementExpression: FirIncrementDecrementExpression, + data: ResolutionMode + ): FirStatement { + return expressionsTransformer.transformIncrementDecrementExpression(incrementDecrementExpression, data) + } + override fun transformEqualityOperatorCall( equalityOperatorCall: FirEqualityOperatorCall, data: ResolutionMode 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 a9f01d9fed4..b1a0df7c2cc 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 @@ -21,13 +21,10 @@ import org.jetbrains.kotlin.fir.extensions.assignAltererExtensions import org.jetbrains.kotlin.fir.extensions.expressionResolutionExtensions import org.jetbrains.kotlin.fir.extensions.extensionService import org.jetbrains.kotlin.fir.references.* -import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference -import org.jetbrains.kotlin.fir.references.builder.buildExplicitSuperReference -import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference +import org.jetbrains.kotlin.fir.references.builder.* import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.* -import org.jetbrains.kotlin.fir.expressions.unwrapSmartcastExpression import org.jetbrains.kotlin.fir.resolve.diagnostics.* import org.jetbrains.kotlin.fir.resolve.inference.FirStubInferenceSession import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor @@ -678,6 +675,124 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT } } + @OptIn(FirContractViolation::class) + override fun transformIncrementDecrementExpression( + incrementDecrementExpression: FirIncrementDecrementExpression, + data: ResolutionMode + ): FirStatement { + incrementDecrementExpression.transformAnnotations(transformer, ResolutionMode.ContextIndependent) + + val originalExpression = incrementDecrementExpression.expression.transformSingle(transformer, ResolutionMode.ContextIndependent) + val expression = when (originalExpression) { + is FirSafeCallExpression -> originalExpression.selector as? FirExpression ?: buildErrorExpression { + source = originalExpression.source + diagnostic = ConeSimpleDiagnostic("Safe call selector expected to be an expression here", DiagnosticKind.Syntax) + } + else -> originalExpression + } + + val desugaredSource = incrementDecrementExpression.source?.fakeElement(KtFakeSourceElementKind.DesugaredIncrementOrDecrement) + + fun generateTemporaryVariable(name: Name, initializer: FirExpression): FirProperty = generateTemporaryVariable( + moduleData = session.moduleData, + source = desugaredSource, + name = name, + initializer = initializer, + typeRef = initializer.typeRef.copyWithNewSource(desugaredSource), + ) + + fun buildAndResolveOperatorCall(receiver: FirExpression): FirFunctionCall = buildFunctionCall { + source = incrementDecrementExpression.operationSource + explicitReceiver = receiver + calleeReference = buildSimpleNamedReference { + val referenceSourceKind = when { + incrementDecrementExpression.isPrefix -> KtFakeSourceElementKind.DesugaredPrefixNameReference + else -> KtFakeSourceElementKind.DesugaredPostfixNameReference + } + source = incrementDecrementExpression.operationSource?.fakeElement(referenceSourceKind) + name = incrementDecrementExpression.operationName + } + origin = FirFunctionCallOrigin.Operator + }.transformSingle(transformer, ResolutionMode.ContextIndependent) + + fun buildAndResolveVariableAssignment(rValue: FirExpression): FirVariableAssignment = buildVariableAssignment { + source = desugaredSource + lValue = buildDesugaredAssignmentValueReferenceExpression { + source = ((expression as? FirErrorExpression)?.expression ?: expression).source + ?.fakeElement(KtFakeSourceElementKind.DesugaredIncrementOrDecrement) + expressionRef = FirExpressionRef().apply { bind(expression.unwrapSmartcastExpression()) } + } + this.rValue = rValue + }.transformSingle(transformer, ResolutionMode.ContextIndependent) + + val block = buildBlock { + source = desugaredSource + annotations += incrementDecrementExpression.annotations + + (expression as? FirQualifiedAccessExpression)?.explicitReceiver + // If a receiver x exists, write it to a temporary variable to prevent multiple calls to it. + // Exceptions: ResolvedQualifiers and ThisReceivers as they can't have side effects when called. + ?.takeIf { it is FirQualifiedAccessExpression && it !is FirThisReceiverExpression } + ?.let { receiver -> + // val = x + statements += generateTemporaryVariable(SpecialNames.RECEIVER, receiver).also { property -> + // Change the expression from x.a to .a + val newReceiverAccess = + property.toQualifiedAccess(fakeSource = receiver.source?.fakeElement(KtFakeSourceElementKind.DesugaredIncrementOrDecrement)) + + if (expression.explicitReceiver == expression.dispatchReceiver) { + expression.replaceDispatchReceiver(newReceiverAccess) + } else { + expression.replaceExtensionReceiver(newReceiverAccess) + } + expression.replaceExplicitReceiver(newReceiverAccess) + } + } + + if (incrementDecrementExpression.isPrefix) { + val targetProperty = expression.calleeReference?.toResolvedPropertySymbol()?.fir + val operatorCall = buildAndResolveOperatorCall(expression) + + // Special case for prefix inc/dec on local variable without delegate where unary-result variable generation is skipped. + if (targetProperty?.isLocal == true && targetProperty.delegate == null) { + // a = a.inc() + statements += buildAndResolveVariableAssignment(operatorCall) + // ^a + statements += targetProperty.toQualifiedAccess(fakeSource = desugaredSource, typeRef = noExpectedType) + // If inc() returns a subtype of its receiver type, the variable access should be smart-casted. + .transform(transformer, withExpectedType(operatorCall.typeRef.coneType)) + } else { + val unaryResultVariable = generateTemporaryVariable(SpecialNames.UNARY_RESULT, operatorCall) + + // val = a.inc() + statements += unaryResultVariable + // a = + statements += buildAndResolveVariableAssignment(unaryResultVariable.toQualifiedAccess(fakeSource = desugaredSource)) + // ^ + statements += unaryResultVariable.toQualifiedAccess(fakeSource = desugaredSource) + } + } else { + val unaryVariable = generateTemporaryVariable(SpecialNames.UNARY, expression) + + // val = a + statements += unaryVariable + // a = .inc() + statements += buildAndResolveVariableAssignment(buildAndResolveOperatorCall(unaryVariable.toQualifiedAccess())) + // ^ + statements += unaryVariable.toQualifiedAccess() + } + }.apply { + replaceTypeRef((statements.last() as FirExpression).typeRef.copyWithNewSource(null)) + } + + return if (originalExpression is FirSafeCallExpression) { + originalExpression.replaceSelector(block) + originalExpression + } else { + block + } + } + override fun transformEqualityOperatorCall( equalityOperatorCall: FirEqualityOperatorCall, data: ResolutionMode @@ -891,14 +1006,6 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT ): FirStatement = whileAnalysing(session, variableAssignment) { variableAssignment.transformAnnotations(transformer, ResolutionMode.ContextIndependent) - val isDesugaredIncrementDecrement = variableAssignment.source?.kind == KtFakeSourceElementKind.DesugaredIncrementOrDecrement - - // Expressions like `++a` are desugared into `a = a.inc()` where the LHS is a FirDesugaredAssignmentValueReferenceExpression - // that's pointing to the not yet resolved `a` on the RHS. For the resolution to work, the RHS must therefore be resolved first. - if (isDesugaredIncrementDecrement) { - variableAssignment.transformRValue(transformer, ResolutionMode.ContextIndependent) - } - variableAssignment.transformLValue(transformer, ResolutionMode.AssignmentLValue(variableAssignment)) val resolvedReference = variableAssignment.calleeReference @@ -926,14 +1033,10 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT } } - val result = if (!isDesugaredIncrementDecrement) { - variableAssignment.transformRValue( - transformer, - withExpectedType(variableAssignment.lValue.typeRef, expectedTypeMismatchIsReportedInChecker = true), - ) - } else { - variableAssignment - } + val result = variableAssignment.transformRValue( + transformer, + withExpectedType(variableAssignment.lValue.typeRef, expectedTypeMismatchIsReportedInChecker = true), + ) (result as? FirVariableAssignment)?.let { dataFlowAnalyzer.exitVariableAssignment(it) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirIncrementDecrementExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirIncrementDecrementExpression.kt new file mode 100644 index 00000000000..24270ba8990 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirIncrementDecrementExpression.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions + +import org.jetbrains.kotlin.KtSourceElement +import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +abstract class FirIncrementDecrementExpression : FirExpression() { + abstract override val source: KtSourceElement? + abstract override val typeRef: FirTypeRef + abstract override val annotations: List + abstract val isPrefix: Boolean + abstract val operationName: Name + abstract val expression: FirExpression + abstract val operationSource: KtSourceElement? + + override fun accept(visitor: FirVisitor, data: D): R = visitor.visitIncrementDecrementExpression(this, data) + + @Suppress("UNCHECKED_CAST") + override fun transform(transformer: FirTransformer, data: D): E = + transformer.transformIncrementDecrementExpression(this, data) as E + + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) + + abstract override fun replaceAnnotations(newAnnotations: List) + + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirIncrementDecrementExpression +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirIncrementDecrementExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirIncrementDecrementExpressionBuilder.kt new file mode 100644 index 00000000000..772119f2e4b --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirIncrementDecrementExpressionBuilder.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("DuplicatedCode") + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.KtSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.builder.toMutableOrEmpty +import org.jetbrains.kotlin.fir.expressions.FirAnnotation +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirIncrementDecrementExpression +import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder +import org.jetbrains.kotlin.fir.expressions.impl.FirIncrementDecrementExpressionImpl +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.name.Name + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirIncrementDecrementExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { + override var source: KtSourceElement? = null + override val annotations: MutableList = mutableListOf() + var isPrefix: Boolean by kotlin.properties.Delegates.notNull() + lateinit var operationName: Name + lateinit var expression: FirExpression + var operationSource: KtSourceElement? = null + + override fun build(): FirIncrementDecrementExpression { + return FirIncrementDecrementExpressionImpl( + source, + annotations.toMutableOrEmpty(), + isPrefix, + operationName, + expression, + operationSource, + ) + } + + + @Deprecated("Modification of 'typeRef' has no impact for FirIncrementDecrementExpressionBuilder", level = DeprecationLevel.HIDDEN) + override var typeRef: FirTypeRef + get() = throw IllegalStateException() + set(_) { + throw IllegalStateException() + } +} + +@OptIn(ExperimentalContracts::class) +inline fun buildIncrementDecrementExpression(init: FirIncrementDecrementExpressionBuilder.() -> Unit): FirIncrementDecrementExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirIncrementDecrementExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIncrementDecrementExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIncrementDecrementExpressionImpl.kt new file mode 100644 index 00000000000..eaf9bd5e9df --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirIncrementDecrementExpressionImpl.kt @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("DuplicatedCode") + +package org.jetbrains.kotlin.fir.expressions.impl + +import org.jetbrains.kotlin.KtSourceElement +import org.jetbrains.kotlin.fir.expressions.FirAnnotation +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirIncrementDecrementExpression +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.fir.visitors.* +import org.jetbrains.kotlin.fir.MutableOrEmptyList +import org.jetbrains.kotlin.fir.builder.toMutableOrEmpty + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +internal class FirIncrementDecrementExpressionImpl( + override val source: KtSourceElement?, + override var annotations: MutableOrEmptyList, + override val isPrefix: Boolean, + override val operationName: Name, + override var expression: FirExpression, + override val operationSource: KtSourceElement?, +) : FirIncrementDecrementExpression() { + override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + + override fun acceptChildren(visitor: FirVisitor, data: D) { + typeRef.accept(visitor, data) + annotations.forEach { it.accept(visitor, data) } + expression.accept(visitor, data) + } + + override fun transformChildren(transformer: FirTransformer, data: D): FirIncrementDecrementExpressionImpl { + typeRef = typeRef.transform(transformer, data) + transformAnnotations(transformer, data) + expression = expression.transform(transformer, data) + return this + } + + override fun transformAnnotations(transformer: FirTransformer, data: D): FirIncrementDecrementExpressionImpl { + annotations.transformInplace(transformer, data) + return this + } + + override fun replaceTypeRef(newTypeRef: FirTypeRef) { + typeRef = newTypeRef + } + + override fun replaceAnnotations(newAnnotations: List) { + annotations = newAnnotations.toMutableOrEmpty() + } +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt index b8df2fc15c2..77bbbdfbb07 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt @@ -82,6 +82,7 @@ import org.jetbrains.kotlin.fir.expressions.FirErrorAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirComparisonExpression import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall import org.jetbrains.kotlin.fir.expressions.FirAssignmentOperatorStatement +import org.jetbrains.kotlin.fir.expressions.FirIncrementDecrementExpression import org.jetbrains.kotlin.fir.expressions.FirEqualityOperatorCall import org.jetbrains.kotlin.fir.expressions.FirWhenExpression import org.jetbrains.kotlin.fir.expressions.FirWhenBranch @@ -214,6 +215,8 @@ abstract class FirDefaultVisitor : FirVisitor() { override fun visitAssignmentOperatorStatement(assignmentOperatorStatement: FirAssignmentOperatorStatement, data: D): R = visitStatement(assignmentOperatorStatement, data) + override fun visitIncrementDecrementExpression(incrementDecrementExpression: FirIncrementDecrementExpression, data: D): R = visitExpression(incrementDecrementExpression, data) + override fun visitAugmentedArraySetCall(augmentedArraySetCall: FirAugmentedArraySetCall, data: D): R = visitStatement(augmentedArraySetCall, data) override fun visitClassReferenceExpression(classReferenceExpression: FirClassReferenceExpression, data: D): R = visitExpression(classReferenceExpression, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt index 3d2b903a897..cd8701bf331 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt @@ -82,6 +82,7 @@ import org.jetbrains.kotlin.fir.expressions.FirErrorAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirComparisonExpression import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall import org.jetbrains.kotlin.fir.expressions.FirAssignmentOperatorStatement +import org.jetbrains.kotlin.fir.expressions.FirIncrementDecrementExpression import org.jetbrains.kotlin.fir.expressions.FirEqualityOperatorCall import org.jetbrains.kotlin.fir.expressions.FirWhenExpression import org.jetbrains.kotlin.fir.expressions.FirWhenBranch @@ -214,6 +215,8 @@ abstract class FirDefaultVisitorVoid : FirVisitorVoid() { override fun visitAssignmentOperatorStatement(assignmentOperatorStatement: FirAssignmentOperatorStatement) = visitStatement(assignmentOperatorStatement) + override fun visitIncrementDecrementExpression(incrementDecrementExpression: FirIncrementDecrementExpression) = visitExpression(incrementDecrementExpression) + override fun visitAugmentedArraySetCall(augmentedArraySetCall: FirAugmentedArraySetCall) = visitStatement(augmentedArraySetCall) override fun visitClassReferenceExpression(classReferenceExpression: FirClassReferenceExpression) = visitExpression(classReferenceExpression) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt index 6e8eff1dc3c..bda864a3460 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt @@ -82,6 +82,7 @@ import org.jetbrains.kotlin.fir.expressions.FirErrorAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirComparisonExpression import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall import org.jetbrains.kotlin.fir.expressions.FirAssignmentOperatorStatement +import org.jetbrains.kotlin.fir.expressions.FirIncrementDecrementExpression import org.jetbrains.kotlin.fir.expressions.FirEqualityOperatorCall import org.jetbrains.kotlin.fir.expressions.FirWhenExpression import org.jetbrains.kotlin.fir.expressions.FirWhenBranch @@ -463,6 +464,10 @@ abstract class FirTransformer : FirVisitor() { return transformElement(assignmentOperatorStatement, data) } + open fun transformIncrementDecrementExpression(incrementDecrementExpression: FirIncrementDecrementExpression, data: D): FirStatement { + return transformElement(incrementDecrementExpression, data) + } + open fun transformEqualityOperatorCall(equalityOperatorCall: FirEqualityOperatorCall, data: D): FirStatement { return transformElement(equalityOperatorCall, data) } @@ -1039,6 +1044,10 @@ abstract class FirTransformer : FirVisitor() { return transformAssignmentOperatorStatement(assignmentOperatorStatement, data) } + final override fun visitIncrementDecrementExpression(incrementDecrementExpression: FirIncrementDecrementExpression, data: D): FirStatement { + return transformIncrementDecrementExpression(incrementDecrementExpression, data) + } + final override fun visitEqualityOperatorCall(equalityOperatorCall: FirEqualityOperatorCall, data: D): FirStatement { return transformEqualityOperatorCall(equalityOperatorCall, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt index cb7a56992e6..bb89ea093f5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt @@ -82,6 +82,7 @@ import org.jetbrains.kotlin.fir.expressions.FirErrorAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirComparisonExpression import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall import org.jetbrains.kotlin.fir.expressions.FirAssignmentOperatorStatement +import org.jetbrains.kotlin.fir.expressions.FirIncrementDecrementExpression import org.jetbrains.kotlin.fir.expressions.FirEqualityOperatorCall import org.jetbrains.kotlin.fir.expressions.FirWhenExpression import org.jetbrains.kotlin.fir.expressions.FirWhenBranch @@ -310,6 +311,8 @@ abstract class FirVisitor { open fun visitAssignmentOperatorStatement(assignmentOperatorStatement: FirAssignmentOperatorStatement, data: D): R = visitElement(assignmentOperatorStatement, data) + open fun visitIncrementDecrementExpression(incrementDecrementExpression: FirIncrementDecrementExpression, data: D): R = visitElement(incrementDecrementExpression, data) + open fun visitEqualityOperatorCall(equalityOperatorCall: FirEqualityOperatorCall, data: D): R = visitElement(equalityOperatorCall, data) open fun visitWhenExpression(whenExpression: FirWhenExpression, data: D): R = visitElement(whenExpression, data) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt index f9ab7719e16..a4e3f2cccab 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt @@ -82,6 +82,7 @@ import org.jetbrains.kotlin.fir.expressions.FirErrorAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirComparisonExpression import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall import org.jetbrains.kotlin.fir.expressions.FirAssignmentOperatorStatement +import org.jetbrains.kotlin.fir.expressions.FirIncrementDecrementExpression import org.jetbrains.kotlin.fir.expressions.FirEqualityOperatorCall import org.jetbrains.kotlin.fir.expressions.FirWhenExpression import org.jetbrains.kotlin.fir.expressions.FirWhenBranch @@ -462,6 +463,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitElement(assignmentOperatorStatement) } + open fun visitIncrementDecrementExpression(incrementDecrementExpression: FirIncrementDecrementExpression) { + visitElement(incrementDecrementExpression) + } + open fun visitEqualityOperatorCall(equalityOperatorCall: FirEqualityOperatorCall) { visitElement(equalityOperatorCall) } @@ -1038,6 +1043,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitAssignmentOperatorStatement(assignmentOperatorStatement) } + final override fun visitIncrementDecrementExpression(incrementDecrementExpression: FirIncrementDecrementExpression, data: Nothing?) { + visitIncrementDecrementExpression(incrementDecrementExpression) + } + final override fun visitEqualityOperatorCall(equalityOperatorCall: FirEqualityOperatorCall, data: Nothing?) { visitEqualityOperatorCall(equalityOperatorCall) } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirGeneration.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirGeneration.kt index 9cbb6968097..ee1d6113d36 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirGeneration.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirGeneration.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.KtFakeSourceElementKind import org.jetbrains.kotlin.KtSourceElement +import org.jetbrains.kotlin.descriptors.EffectiveVisibility import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fakeElement @@ -14,7 +15,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirVariable import org.jetbrains.kotlin.fir.declarations.builder.buildProperty -import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl import org.jetbrains.kotlin.fir.expressions.FirAnnotation import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression @@ -25,15 +26,17 @@ import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef import org.jetbrains.kotlin.name.Name -fun FirVariable.toQualifiedAccess(): FirQualifiedAccessExpression = buildPropertyAccessExpression { - val fakeSource = this@toQualifiedAccess.source?.fakeElement(KtFakeSourceElementKind.ReferenceInAtomicQualifiedAccess) +fun FirVariable.toQualifiedAccess( + fakeSource: KtSourceElement? = source?.fakeElement(KtFakeSourceElementKind.ReferenceInAtomicQualifiedAccess), + typeRef: FirTypeRef = returnTypeRef +): FirQualifiedAccessExpression = buildPropertyAccessExpression { source = fakeSource calleeReference = buildResolvedNamedReference { source = fakeSource name = this@toQualifiedAccess.name resolvedSymbol = this@toQualifiedAccess.symbol } - typeRef = this@toQualifiedAccess.returnTypeRef + this.typeRef = typeRef } fun generateTemporaryVariable( @@ -42,7 +45,7 @@ fun generateTemporaryVariable( name: Name, initializer: FirExpression, typeRef: FirTypeRef? = null, - extractedAnnotations: Collection? = null, + extractedAnnotations: Collection? = null ): FirProperty = buildProperty { this.source = source @@ -56,7 +59,7 @@ fun generateTemporaryVariable( symbol = FirPropertySymbol(name) isVar = false isLocal = true - status = FirDeclarationStatusImpl(Visibilities.Local, Modality.FINAL) + status = FirResolvedDeclarationStatusImpl(Visibilities.Local, Modality.FINAL, EffectiveVisibility.Local) if (extractedAnnotations != null) { // LT extracts annotations ahead. // PSI extracts annotations on demand. Use a similar util in [PsiConversionUtils] diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt index 7698b3f0a73..3cc51c9a2ab 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/renderer/FirRenderer.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.util.OperatorNameConventions import java.util.* class FirRenderer( @@ -1022,6 +1023,14 @@ class FirRenderer( print(")") } + override fun visitIncrementDecrementExpression(incrementDecrementExpression: FirIncrementDecrementExpression) { + annotationRenderer?.render(incrementDecrementExpression) + val operator = if (incrementDecrementExpression.operationName == OperatorNameConventions.INC) "++" else "--" + if (incrementDecrementExpression.isPrefix) print(operator) + incrementDecrementExpression.expression.accept(visitor) + if (!incrementDecrementExpression.isPrefix) print(operator) + } + override fun visitEqualityOperatorCall(equalityOperatorCall: FirEqualityOperatorCall) { annotationRenderer?.render(equalityOperatorCall) print(equalityOperatorCall.operation.operator) 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 76bdd0a25e6..847bb75ac27 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 @@ -104,6 +104,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() { val comparisonExpression by element(Expression, expression) val typeOperatorCall by element(Expression, expression, call) val assignmentOperatorStatement by element(Expression, statement) + val incrementDecrementExpression by element(Expression, expression) val equalityOperatorCall by element(Expression, expression, call) val whenExpression by element(Expression, expression, resolvable) val whenBranch by element(Expression) 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 a5671079971..bd6e79744fd 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 @@ -317,6 +317,8 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(assignmentOperatorStatement) + impl(incrementDecrementExpression) + impl(equalityOperatorCall) { default("typeRef", "FirImplicitBooleanTypeRef(null)") useTypes(implicitBooleanTypeRefType) 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 03be26cae17..ff7f4706de0 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 @@ -254,6 +254,13 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild +field("rightArgument", expression).withTransform() } + incrementDecrementExpression.configure { + +booleanField("isPrefix") + +field("operationName", nameType) + +field("expression", expression) + +field("operationSource", sourceElementType, nullable = true) + } + equalityOperatorCall.configure { +field("operation", operationType) } diff --git a/compiler/testData/codegen/box/intrinsics/prefixIncDec.kt b/compiler/testData/codegen/box/intrinsics/prefixIncDec.kt index 00321feb2f9..074e9df8e47 100644 --- a/compiler/testData/codegen/box/intrinsics/prefixIncDec.kt +++ b/compiler/testData/codegen/box/intrinsics/prefixIncDec.kt @@ -1,3 +1,6 @@ +// IGNORE_BACKEND_K2: ANY +// Behavior changed in K2, see KT-42077 + public var inc: Int = 0 public var propInc: Int = 0 @@ -26,4 +29,4 @@ fun box(): String { if (propDec != -1) return "fail in prefix decrement: ${propDec} != -1" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt b/compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt new file mode 100644 index 00000000000..fc734d42c24 --- /dev/null +++ b/compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt @@ -0,0 +1,34 @@ +// IGNORE_BACKEND_K1: ANY +// Behavior changed in K2, see KT-42077 +// IGNORE_BACKEND: WASM +// SKIP_NODE_JS + +public var inc: Int = 0 + +public var propInc: Int = 0 + get() {++inc; return field} + set(a: Int) { + ++inc + field = a + } + +public var dec: Int = 0 + +public var propDec: Int = 0 + get() { --dec; return field} + set(a: Int) { + --dec + field = a + } + +fun box(): String { + ++propInc + if (inc != 2) return "fail in prefix increment: ${inc} != 2" + if (propInc != 1) return "fail in prefix increment: ${propInc} != 1" + + --propDec + if (dec != -2) return "fail in prefix decrement: ${dec} != -2" + if (propDec != -1) return "fail in prefix decrement: ${propDec} != -1" + + return "OK" +} diff --git a/compiler/testData/codegen/box/statics/incInClassObject.kt b/compiler/testData/codegen/box/statics/incInClassObject.kt index f4cfe90e680..a67d2c25236 100644 --- a/compiler/testData/codegen/box/statics/incInClassObject.kt +++ b/compiler/testData/codegen/box/statics/incInClassObject.kt @@ -1,3 +1,6 @@ +// IGNORE_BACKEND_K2: ANY +// Behavior changed in K2, see KT-42077 + class A { companion object { private var r: Int = 1; @@ -70,4 +73,4 @@ fun box() : String { if (p4 != 3 || A.holder != "getR4setR4:getR4setR4getR4getR4") return "fail 4: $p4 ${A.holder}" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/statics/incInClassObjectFir.kt b/compiler/testData/codegen/box/statics/incInClassObjectFir.kt new file mode 100644 index 00000000000..996b86ed9e3 --- /dev/null +++ b/compiler/testData/codegen/box/statics/incInClassObjectFir.kt @@ -0,0 +1,78 @@ +// IGNORE_BACKEND_K1: ANY +// Behavior changed in K2, see KT-42077 +// IGNORE_BACKEND: WASM +// SKIP_NODE_JS + +class A { + companion object { + private var r: Int = 1; + + fun test(): Int { + r++ + ++r + return r + } + + var holder: String = "" + + var r2: Int = 1 + get() { + holder += "getR2" + return field + } + + fun test2() : Int { + r2++ + ++r2 + return r2 + } + + var r3: Int = 1 + set(p: Int) { + holder += "setR3" + field = p + } + + fun test3() : Int { + r3++ + ++r3 + return r3 + } + + var r4: Int = 1 + get() { + holder += "getR4" + return field + } + set(p: Int) { + holder += "setR4" + field = p + } + + fun test4() : Int { + r4++ + holder += ":" + ++r4 + return r4 + } + } +} + +fun box() : String { + val p = A.test() + if (p != 3) return "fail 1: $p" + + val p2 = A.test2() + var holderValue = A.holder + if (p2 != 3 || holderValue != "getR2getR2getR2") return "fail 2: $p2 ${holderValue}" + + A.holder = "" + val p3 = A.test3() + if (p3 != 3 || A.holder != "setR3setR3") return "fail 3: $p3 ${A.holder}" + + A.holder = "" + val p4 = A.test4() + if (p4 != 3 || A.holder != "getR4setR4:getR4setR4getR4") return "fail 4: $p4 ${A.holder}" + + return "OK" +} diff --git a/compiler/testData/codegen/box/statics/incInObject.kt b/compiler/testData/codegen/box/statics/incInObject.kt index c1f48692d36..b655596ddbd 100644 --- a/compiler/testData/codegen/box/statics/incInObject.kt +++ b/compiler/testData/codegen/box/statics/incInObject.kt @@ -1,3 +1,6 @@ +// IGNORE_BACKEND_K2: ANY +// Behavior changed in K2, see KT-42077 + object A { private var r: Int = 1; @@ -68,4 +71,4 @@ fun box() : String { if (p4 != 3 || A.holder != "getR4setR4:getR4setR4getR4getR4") return "fail 4: $p4 ${A.holder}" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/statics/incInObjectFir.kt b/compiler/testData/codegen/box/statics/incInObjectFir.kt new file mode 100644 index 00000000000..d97f9bd294f --- /dev/null +++ b/compiler/testData/codegen/box/statics/incInObjectFir.kt @@ -0,0 +1,76 @@ +// IGNORE_BACKEND_K1: ANY +// Behavior changed in K2, see KT-42077 +// IGNORE_BACKEND: WASM +// SKIP_NODE_JS + +object A { + private var r: Int = 1; + + fun test() : Int { + r++ + ++r + return r + } + + var holder: String = "" + + var r2: Int = 1 + get() { + holder += "getR2" + return field + } + + fun test2() : Int { + r2++ + ++r2 + return r2 + } + + var r3: Int = 1 + set(p: Int) { + holder += "setR3" + field = p + } + + fun test3() : Int { + r3++ + ++r3 + return r3 + } + + var r4: Int = 1 + get() { + holder += "getR4" + return field + } + set(p: Int) { + holder += "setR4" + field = p + } + + fun test4() : Int { + r4++ + holder += ":" + ++r4 + return r4 + } +} + +fun box() : String { + val p = A.test() + if (p != 3) return "fail 1: $p" + + val p2 = A.test2() + val holderValue = A.holder + if (p2 != 3 || holderValue != "getR2getR2getR2") return "fail 2: $p2 ${holderValue}" + + A.holder = "" + val p3 = A.test3() + if (p3 != 3 || A.holder != "setR3setR3") return "fail 3: $p3 ${A.holder}" + + A.holder = "" + val p4 = A.test4() + if (p4 != 3 || A.holder != "getR4setR4:getR4setR4getR4") return "fail 4: $p4 ${A.holder}" + + return "OK" +} diff --git a/compiler/testData/diagnostics/tests/IncDec.fir.kt b/compiler/testData/diagnostics/tests/IncDec.fir.kt index fa8326da3a6..21c5597f2c0 100644 --- a/compiler/testData/diagnostics/tests/IncDec.fir.kt +++ b/compiler/testData/diagnostics/tests/IncDec.fir.kt @@ -22,9 +22,9 @@ class WrongIncDec() { fun testWrongIncDec() { var x = WrongIncDec() - x++ + x++ ++x - x-- + x-- --x } @@ -41,6 +41,6 @@ fun testUnitIncDec() { --x x = x++ x = x-- - x = ++x - x = --x + x = ++x + x = --x } diff --git a/compiler/testData/diagnostics/tests/LValueAssignment.fir.kt b/compiler/testData/diagnostics/tests/LValueAssignment.fir.kt index e02d3a17c02..28fc003448a 100644 --- a/compiler/testData/diagnostics/tests/LValueAssignment.fir.kt +++ b/compiler/testData/diagnostics/tests/LValueAssignment.fir.kt @@ -106,7 +106,7 @@ class Test() { fun testIncompleteSyntax() { val s = "s" - ++s. + ++s. } fun testVariables() { diff --git a/compiler/testData/diagnostics/tests/incrementDecrementOnFullyQualified.kt b/compiler/testData/diagnostics/tests/incrementDecrementOnFullyQualified.kt new file mode 100644 index 00000000000..24a52d4d919 --- /dev/null +++ b/compiler/testData/diagnostics/tests/incrementDecrementOnFullyQualified.kt @@ -0,0 +1,10 @@ +// SKIP_TXT +// FIR_IDENTICAL + +package foo.bar + +var baz = 1 + +fun test() { + foo.bar.baz++ +} diff --git a/compiler/testData/diagnostics/tests/incrementDecrementOnObject.fir.kt b/compiler/testData/diagnostics/tests/incrementDecrementOnObject.fir.kt new file mode 100644 index 00000000000..1228f4b7980 --- /dev/null +++ b/compiler/testData/diagnostics/tests/incrementDecrementOnObject.fir.kt @@ -0,0 +1,22 @@ +// SKIP_TXT +// ISSUE: KT-56659 + +object AAA { operator fun inc(): AAA = this } + +fun test1() { + AAA++ +} + +fun test2() { + ++AAA +} + +fun test3() { + var x = AAA + x = AAA++ +} + +fun test4() { + var x = AAA + x = ++AAA +} diff --git a/compiler/testData/diagnostics/tests/incrementDecrementOnObject.kt b/compiler/testData/diagnostics/tests/incrementDecrementOnObject.kt new file mode 100644 index 00000000000..259ddbcd19c --- /dev/null +++ b/compiler/testData/diagnostics/tests/incrementDecrementOnObject.kt @@ -0,0 +1,22 @@ +// SKIP_TXT +// ISSUE: KT-56659 + +object AAA { operator fun inc(): AAA = this } + +fun test1() { + AAA++ +} + +fun test2() { + ++AAA +} + +fun test3() { + var x = AAA + x = AAA++ +} + +fun test4() { + var x = AAA + x = ++AAA +} diff --git a/compiler/testData/diagnostics/tests/inline/unaryExpressions/mathOperation.fir.kt b/compiler/testData/diagnostics/tests/inline/unaryExpressions/mathOperation.fir.kt deleted file mode 100644 index f11639df69c..00000000000 --- a/compiler/testData/diagnostics/tests/inline/unaryExpressions/mathOperation.fir.kt +++ /dev/null @@ -1,36 +0,0 @@ -// !LANGUAGE: +ForbidExtensionCallsOnInlineFunctionalParameters -// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -VAL_REASSIGNMENT -UNUSED_CHANGED_VALUE -VARIABLE_EXPECTED - -inline operator fun Function1.unaryPlus() = this -operator fun Function1.unaryMinus() = this -inline operator fun Function1.inc() = this -operator fun Function1.dec() = this - -inline operator fun @ExtensionFunctionType Function2.unaryPlus(){} -operator fun @ExtensionFunctionType Function2.unaryMinus(){} -inline operator fun @ExtensionFunctionType Function2.inc() = this -operator fun @ExtensionFunctionType Function2.dec() = this - -inline fun inlineFunWithInvoke(s: (p: T) -> V, ext: T.(p: T) -> V) { - +s - -s - s++ - ++s - s-- - --s - +ext - -ext - ext++ - ++ext - ext-- - --ext -} - -inline fun Function1.inlineFunWithInvoke() { - +this - -this - this++ - ++this - this-- - --this -} diff --git a/compiler/testData/diagnostics/tests/inline/unaryExpressions/mathOperation.kt b/compiler/testData/diagnostics/tests/inline/unaryExpressions/mathOperation.kt index c1a280bac92..08430feb482 100644 --- a/compiler/testData/diagnostics/tests/inline/unaryExpressions/mathOperation.kt +++ b/compiler/testData/diagnostics/tests/inline/unaryExpressions/mathOperation.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +ForbidExtensionCallsOnInlineFunctionalParameters // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -VAL_REASSIGNMENT -UNUSED_CHANGED_VALUE -VARIABLE_EXPECTED diff --git a/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.fir.kt b/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.fir.kt index 978a6ab119c..4ae5957be57 100644 --- a/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.fir.kt @@ -40,7 +40,7 @@ open class A { fun foo() { topLevelFun() topLevelFun(1) - topLevelProperty++ + topLevelProperty++ "".topLevelExtensionFun() 1.topLevelExtensionFun() "".topLevelExtensionProperty diff --git a/compiler/testData/diagnostics/testsWithStdLib/builderInference/unsafeAssignmentExtra.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/builderInference/unsafeAssignmentExtra.fir.txt index 2189bd14d9c..080dc258912 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/builderInference/unsafeAssignmentExtra.fir.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/builderInference/unsafeAssignmentExtra.fir.txt @@ -30,16 +30,22 @@ FILE: unsafeAssignmentExtra.fir.kt lval value: R|Foo| = R|/myBuilder|( = myBuilder@fun R|Foo|.(): R|kotlin/Unit| { this@R|special/anonymous|.R|SubstitutionOverride|>|.R|SubstitutionOverride|(Int(0), Int(123)) this@R|special/anonymous|.R|SubstitutionOverride| = Int(45) - lval : R|kotlin/Int| = this@R|special/anonymous|.R|SubstitutionOverride| - this@R|special/anonymous|.R|SubstitutionOverride| = R|/|.#() - R|/| + { + lval : R|kotlin/Int| = this@R|special/anonymous|.R|SubstitutionOverride| + this@R|special/anonymous|.R|SubstitutionOverride| = R|/|.#() + R|/| + } + R|/bar|(::R|SubstitutionOverride|) when () { (this@R|special/anonymous|.R|SubstitutionOverride| is R|kotlin/Int|) -> { this@R|special/anonymous|.R|SubstitutionOverride| = Int(67) - lval : R|kotlin/Int| = this@R|special/anonymous|.R|SubstitutionOverride| - this@R|special/anonymous|.R|SubstitutionOverride| = R|/|.#() - R|/| + { + lval : R|kotlin/Int| = this@R|special/anonymous|.R|SubstitutionOverride| + this@R|special/anonymous|.R|SubstitutionOverride| = R|/|.#() + R|/| + } + R|/bar|(::R|SubstitutionOverride|) } } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.ir.txt index 85e407df362..078619fbe5d 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.ir.txt @@ -185,22 +185,24 @@ FILE fqName: fileName:/unaryOperators.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:.Result $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.Result [val] - GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null - SET_VAR 'var result: .Result [var] declared in .box' type=kotlin.Unit origin=EQ - CALL 'public final fun inc (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null - $receiver: GET_VAR 'val tmp_1: .Result [val] declared in .box.' type=.Result origin=null - _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'val tmp_1: .Result [val] declared in .box.' type=.Result origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.Result [val] - GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null - SET_VAR 'var result: .Result [var] declared in .box' type=kotlin.Unit origin=EQ - CALL 'public final fun inc (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null - $receiver: GET_VAR 'val tmp_2: .Result [val] declared in .box.' type=.Result origin=null - _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + BLOCK type=.Result origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.Result [val] + GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null + SET_VAR 'var result: .Result [var] declared in .box' type=kotlin.Unit origin=EQ + CALL 'public final fun inc (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null + $receiver: GET_VAR 'val tmp_1: .Result [val] declared in .box.' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + GET_VAR 'val tmp_1: .Result [val] declared in .box.' type=.Result origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'val tmp_2: .Result [val] declared in .box.' type=.Result origin=null + BLOCK type=.Result origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.Result [val] + GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null + SET_VAR 'var result: .Result [var] declared in .box' type=kotlin.Unit origin=EQ + CALL 'public final fun inc (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null + $receiver: GET_VAR 'val tmp_2: .Result [val] declared in .box.' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + GET_VAR 'val tmp_2: .Result [val] declared in .box.' type=.Result origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun unaryMinus (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null $receiver: GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null @@ -209,14 +211,15 @@ FILE fqName: fileName:/unaryOperators.kt CALL 'public final fun unaryPlus (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null $receiver: GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:.Result [val] - GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null - SET_VAR 'var result: .Result [var] declared in .box' type=kotlin.Unit origin=EQ - CALL 'public final fun dec (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null - $receiver: GET_VAR 'val tmp_3: .Result [val] declared in .box.' type=.Result origin=null - _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null RETURN type=kotlin.Nothing from='local final fun (): .Result declared in .box' - GET_VAR 'val tmp_3: .Result [val] declared in .box.' type=.Result origin=null + BLOCK type=.Result origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:.Result [val] + GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null + SET_VAR 'var result: .Result [var] declared in .box' type=kotlin.Unit origin=EQ + CALL 'public final fun dec (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null + $receiver: GET_VAR 'val tmp_3: .Result [val] declared in .box.' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + GET_VAR 'val tmp_3: .Result [val] declared in .box.' type=.Result origin=null RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' WHEN type=kotlin.String origin=IF BRANCH diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.kt.txt index 73e86e1ff3c..a758eeff982 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.kt.txt @@ -72,17 +72,23 @@ operator fun Result.dec(_context_receiver_0: Int): Result { fun box(): String { var result: Result = Result(i = 0) with(receiver = 1, block = local fun Int.(): Result { - val : Result = result - result = .inc(_context_receiver_0 = $this$with) - /*~> Unit */ - val : Result = result - result = .inc(_context_receiver_0 = $this$with) - /*~> Unit */ + { // BLOCK + val : Result = result + result = .inc(_context_receiver_0 = $this$with) + + } /*~> Unit */ + { // BLOCK + val : Result = result + result = .inc(_context_receiver_0 = $this$with) + + } /*~> Unit */ result.unaryMinus(_context_receiver_0 = $this$with) /*~> Unit */ result.unaryPlus(_context_receiver_0 = $this$with) /*~> Unit */ - val : Result = result - result = .dec(_context_receiver_0 = $this$with) - return + return { // BLOCK + val : Result = result + result = .dec(_context_receiver_0 = $this$with) + + } } ) /*~> Unit */ return when { diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt index 1ea8b40ef6e..2b6b2122bc6 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.ir.txt @@ -104,16 +104,17 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt WHILE label=Outer origin=WHILE_LOOP condition: CONST Boolean type=kotlin.Boolean value=true body: BLOCK type=kotlin.Unit origin=null - SET_VAR 'var i: kotlin.Int [var] declared in .test5' type=kotlin.Unit origin=PREFIX_INCR - CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'var i: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'var i: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=null + SET_VAR 'var i: kotlin.Int [var] declared in .test5' type=kotlin.Unit origin=PREFIX_INCR + CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var i: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null + GET_VAR 'var i: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null VAR name:j type:kotlin.Int [var] CONST Int type=kotlin.Int value=0 BLOCK type=kotlin.Unit origin=null DO_WHILE label=Inner origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + body: BLOCK type=kotlin.Int origin=null SET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Unit origin=PREFIX_INCR CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: GET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt index b885405db64..ca09f0d0113 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt @@ -65,14 +65,16 @@ fun test4(ss: List?) { fun test5() { var i: Int = 0 Outer@ while (true) { // BLOCK - i = i.inc() - i /*~> Unit */ + { // BLOCK + i = i.inc() + i + } /*~> Unit */ var j: Int = 0 { // BLOCK - Inner@ do// COMPOSITE { - j = j.inc() - j - // } while (when { + Inner@ do{ // BLOCK + j = j.inc() + j + } while (when { greaterOrEqual(arg0 = j, arg1 = 3) -> false else -> break@Inner }) diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.ir.txt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.ir.txt index cc22f20c9c3..8c280cb6a69 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.ir.txt @@ -111,11 +111,12 @@ FILE fqName: fileName:/breakContinueInWhen.kt BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP - SET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Unit origin=PREFIX_INCR - CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=null + SET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Unit origin=PREFIX_INCR + CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null WHEN type=kotlin.Unit origin=WHEN BRANCH if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt index ca091003d13..02f03b8d174 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt @@ -60,8 +60,10 @@ fun testContinueDoWhile() { var s: String = "" { // BLOCK do// COMPOSITE { - k = k.inc() - k /*~> Unit */ + { // BLOCK + k = k.inc() + k + } /*~> Unit */ when { greater(arg0 = k, arg1 = 2) -> continue } diff --git a/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.ir.txt b/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.ir.txt index 0db692b1e28..0b85ea40938 100644 --- a/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.ir.txt @@ -141,39 +141,36 @@ FILE fqName: fileName:/complexAugmentedAssignment.kt GET_VAR 'val tmp_3: kotlin.Int [val] declared in .test1' type=kotlin.Int origin=null FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:.X1 [val] - GET_OBJECT 'CLASS OBJECT name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1 - VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] - CALL 'public final fun (): kotlin.Int declared in .X1' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'val tmp_4: .X1 [val] declared in .test2' type=.X1 origin=null - CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .X1' type=kotlin.Unit origin=EQ - $this: GET_VAR 'val tmp_4: .X1 [val] declared in .test2' type=.X1 origin=null - : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_5: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'val tmp_5: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:.X1.X2 [val] - GET_OBJECT 'CLASS OBJECT name:X2 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1.X2 - VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val] - CALL 'public final fun (): kotlin.Int declared in .X1.X2' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'val tmp_6: .X1.X2 [val] declared in .test2' type=.X1.X2 origin=null - CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .X1.X2' type=kotlin.Unit origin=EQ - $this: GET_VAR 'val tmp_6: .X1.X2 [val] declared in .test2' type=.X1.X2 origin=null - : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_7: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val] + CALL 'public final fun (): kotlin.Int declared in .X1' type=kotlin.Int origin=GET_PROPERTY + $this: GET_OBJECT 'CLASS OBJECT name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1 + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .X1' type=kotlin.Unit origin=EQ + $this: GET_OBJECT 'CLASS OBJECT name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1 + : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_4: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + GET_VAR 'val tmp_4: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'val tmp_7: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_8 type:.X1.X2.X3 [val] - GET_OBJECT 'CLASS OBJECT name:X3 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1.X2.X3 - VAR IR_TEMPORARY_VARIABLE name:tmp_9 type:kotlin.Int [val] - CALL 'public final fun (): kotlin.Int declared in .X1.X2.X3' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'val tmp_8: .X1.X2.X3 [val] declared in .test2' type=.X1.X2.X3 origin=null - CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .X1.X2.X3' type=kotlin.Unit origin=EQ - $this: GET_VAR 'val tmp_8: .X1.X2.X3 [val] declared in .test2' type=.X1.X2.X3 origin=null - : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_9: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] + CALL 'public final fun (): kotlin.Int declared in .X1.X2' type=kotlin.Int origin=GET_PROPERTY + $this: GET_OBJECT 'CLASS OBJECT name:X2 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1.X2 + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .X1.X2' type=kotlin.Unit origin=EQ + $this: GET_OBJECT 'CLASS OBJECT name:X2 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1.X2 + : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_5: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + GET_VAR 'val tmp_5: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'val tmp_9: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.Int [val] + CALL 'public final fun (): kotlin.Int declared in .X1.X2.X3' type=kotlin.Int origin=GET_PROPERTY + $this: GET_OBJECT 'CLASS OBJECT name:X3 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1.X2.X3 + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .X1.X2.X3' type=kotlin.Unit origin=EQ + $this: GET_OBJECT 'CLASS OBJECT name:X3 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1.X2.X3 + : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_6: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + GET_VAR 'val tmp_6: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B CONSTRUCTOR visibility:public <> (s:kotlin.Int) returnType:.B [primary] diff --git a/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.kt.txt b/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.kt.txt index 2f6d97119cd..4e6764f92ee 100644 --- a/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.kt.txt @@ -54,18 +54,21 @@ fun test1(a: IntArray) { } fun test2() { - val : X1 = X1 - val : Int = .() - .( = .inc()) - /*~> Unit */ - val : X2 = X2 - val : Int = .() - .( = .inc()) - /*~> Unit */ - val : X3 = X3 - val : Int = .() - .( = .inc()) - /*~> Unit */ + { // BLOCK + val : Int = X1.() + X1.( = .inc()) + + } /*~> Unit */ + { // BLOCK + val : Int = X2.() + X2.( = .inc()) + + } /*~> Unit */ + { // BLOCK + val : Int = X3.() + X3.( = .inc()) + + } /*~> Unit */ } class B { diff --git a/compiler/testData/ir/irText/expressions/incrementDecrement.fir.ir.txt b/compiler/testData/ir/irText/expressions/incrementDecrement.fir.ir.txt index c37266d58ef..b6cdda570b5 100644 --- a/compiler/testData/ir/irText/expressions/incrementDecrement.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/incrementDecrement.fir.ir.txt @@ -67,58 +67,48 @@ FILE fqName: fileName:/incrementDecrement.kt BLOCK_BODY VAR name:p1 type:kotlin.Int [val] BLOCK type=kotlin.Int origin=null - CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ - : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY - CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : GET_VAR 'val tmp_2: kotlin.Int [val] declared in .testPropPrefix' type=kotlin.Int origin=null + GET_VAR 'val tmp_2: kotlin.Int [val] declared in .testPropPrefix' type=kotlin.Int origin=null VAR name:p2 type:kotlin.Int [val] BLOCK type=kotlin.Int origin=null - CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ - : CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY - CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : GET_VAR 'val tmp_3: kotlin.Int [val] declared in .testPropPrefix' type=kotlin.Int origin=null + GET_VAR 'val tmp_3: kotlin.Int [val] declared in .testPropPrefix' type=kotlin.Int origin=null FUN name:testPropPostfix visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:p1 type:kotlin.Int [val] BLOCK type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val] CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_2: kotlin.Int [val] declared in .testPropPostfix' type=kotlin.Int origin=null - GET_VAR 'val tmp_2: kotlin.Int [val] declared in .testPropPostfix' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_4: kotlin.Int [val] declared in .testPropPostfix' type=kotlin.Int origin=null + GET_VAR 'val tmp_4: kotlin.Int [val] declared in .testPropPostfix' type=kotlin.Int origin=null VAR name:p2 type:kotlin.Int [val] BLOCK type=kotlin.Int origin=null - CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ - : CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] + CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY - CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : GET_VAR 'val tmp_5: kotlin.Int [val] declared in .testPropPostfix' type=kotlin.Int origin=null + GET_VAR 'val tmp_5: kotlin.Int [val] declared in .testPropPostfix' type=kotlin.Int origin=null FUN name:testArrayPrefix visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:a1 type:kotlin.Int [val] - BLOCK type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.IntArray [val] - CALL 'public final fun (): kotlin.IntArray declared in ' type=kotlin.IntArray origin=GET_PROPERTY - VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val] - CONST Int type=kotlin.Int value=0 - VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] - CALL 'public final fun inc (): 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_3: kotlin.IntArray [val] declared in .testArrayPrefix' type=kotlin.IntArray origin=null - index: GET_VAR 'val tmp_4: kotlin.Int [val] declared in .testArrayPrefix' 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_3: kotlin.IntArray [val] declared in .testArrayPrefix' type=kotlin.IntArray origin=null - index: GET_VAR 'val tmp_4: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null - value: GET_VAR 'val tmp_5: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null - GET_VAR 'val tmp_5: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null - VAR name:a2 type:kotlin.Int [val] BLOCK type=kotlin.Int origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.IntArray [val] CALL 'public final fun (): kotlin.IntArray declared in ' type=kotlin.IntArray origin=GET_PROPERTY VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val] CONST Int type=kotlin.Int value=0 VAR IR_TEMPORARY_VARIABLE name:tmp_8 type:kotlin.Int [val] - CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + CALL 'public final fun inc (): 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_6: kotlin.IntArray [val] declared in .testArrayPrefix' type=kotlin.IntArray origin=null index: GET_VAR 'val tmp_7: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null @@ -127,25 +117,25 @@ FILE fqName: fileName:/incrementDecrement.kt index: GET_VAR 'val tmp_7: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null value: GET_VAR 'val tmp_8: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null GET_VAR 'val tmp_8: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null - FUN name:testArrayPostfix visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - VAR name:a1 type:kotlin.Int [val] + VAR name:a2 type:kotlin.Int [val] BLOCK type=kotlin.Int origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_9 type:kotlin.IntArray [val] CALL 'public final fun (): kotlin.IntArray declared in ' type=kotlin.IntArray origin=GET_PROPERTY VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:kotlin.Int [val] CONST Int type=kotlin.Int value=0 VAR IR_TEMPORARY_VARIABLE name:tmp_11 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: GET_VAR 'val tmp_9: kotlin.IntArray [val] declared in .testArrayPostfix' type=kotlin.IntArray origin=null - index: GET_VAR 'val tmp_10: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null + CALL 'public final fun dec (): 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_9: kotlin.IntArray [val] declared in .testArrayPrefix' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_10: kotlin.Int [val] declared in .testArrayPrefix' 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_9: kotlin.IntArray [val] declared in .testArrayPostfix' type=kotlin.IntArray origin=null - index: GET_VAR 'val tmp_10: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null - value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_11: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null - GET_VAR 'val tmp_11: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null - VAR name:a2 type:kotlin.Int [val] + $this: GET_VAR 'val tmp_9: kotlin.IntArray [val] declared in .testArrayPrefix' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_10: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null + value: GET_VAR 'val tmp_11: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null + GET_VAR 'val tmp_11: kotlin.Int [val] declared in .testArrayPrefix' type=kotlin.Int origin=null + FUN name:testArrayPostfix visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:a1 type:kotlin.Int [val] BLOCK type=kotlin.Int origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_12 type:kotlin.IntArray [val] CALL 'public final fun (): kotlin.IntArray declared in ' type=kotlin.IntArray origin=GET_PROPERTY @@ -158,6 +148,22 @@ FILE fqName: fileName:/incrementDecrement.kt 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_12: kotlin.IntArray [val] declared in .testArrayPostfix' type=kotlin.IntArray origin=null index: GET_VAR 'val tmp_13: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null - value: CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: GET_VAR 'val tmp_14: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null GET_VAR 'val tmp_14: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null + VAR name:a2 type:kotlin.Int [val] + BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_15 type:kotlin.IntArray [val] + CALL 'public final fun (): kotlin.IntArray declared in ' type=kotlin.IntArray origin=GET_PROPERTY + VAR IR_TEMPORARY_VARIABLE name:tmp_16 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + VAR IR_TEMPORARY_VARIABLE name:tmp_17 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: GET_VAR 'val tmp_15: kotlin.IntArray [val] declared in .testArrayPostfix' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_16: kotlin.Int [val] declared in .testArrayPostfix' 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_15: kotlin.IntArray [val] declared in .testArrayPostfix' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_16: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null + value: CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_17: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null + GET_VAR 'val tmp_17: kotlin.Int [val] declared in .testArrayPostfix' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/incrementDecrement.fir.kt.txt b/compiler/testData/ir/irText/expressions/incrementDecrement.fir.kt.txt index 547e97490d8..fc3fe903eda 100644 --- a/compiler/testData/ir/irText/expressions/incrementDecrement.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/incrementDecrement.fir.kt.txt @@ -35,12 +35,14 @@ fun testVarPostfix() { fun testPropPrefix() { val p1: Int = { // BLOCK - ( = ().inc()) - () + val : Int = ().inc() + ( = ) + } val p2: Int = { // BLOCK - ( = ().dec()) - () + val : Int = ().dec() + ( = ) + } } @@ -51,8 +53,9 @@ fun testPropPostfix() { } val p2: Int = { // BLOCK - ( = ().dec()) - () + val : Int = ().dec() + ( = ) + } } diff --git a/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.ir.txt b/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.ir.txt index d706e82b067..0782fdd2a66 100644 --- a/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.ir.txt @@ -9,17 +9,18 @@ FILE fqName: fileName:/javaSyntheticGenericPropertyAccess.kt CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in .J' type=kotlin.Unit origin=EQ $this: GET_VAR 'j: .J.test> declared in .test' type=.J.test> origin=null x: CONST Int type=kotlin.Int value=1 - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.J.test> [val] - GET_VAR 'j: .J.test> declared in .test' type=.J.test> origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] - CALL 'public open fun getFoo (): kotlin.Int declared in .J' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'val tmp_0: .J.test> [val] declared in .test' type=.J.test> origin=null - CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in .J' type=kotlin.Unit origin=EQ - $this: GET_VAR 'val tmp_0: .J.test> [val] declared in .test' type=.J.test> origin=null - x: 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 .test' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'val tmp_1: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.J.test> [val] + GET_VAR 'j: .J.test> declared in .test' type=.J.test> origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + CALL 'public open fun getFoo (): kotlin.Int declared in .J' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'val tmp_0: .J.test> [val] declared in .test' type=.J.test> origin=null + CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in .J' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val tmp_0: .J.test> [val] declared in .test' type=.J.test> origin=null + x: 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 .test' type=kotlin.Int origin=null + GET_VAR 'val tmp_1: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in .J' type=kotlin.Unit origin=EQ $this: GET_VAR 'j: .J.test> declared in .test' type=.J.test> origin=null x: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.kt.txt b/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.kt.txt index bc01ad1333c..3a68ff1aa71 100644 --- a/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.kt.txt @@ -1,9 +1,11 @@ fun test(j: J) { j.getFoo() /*~> Unit */ j.setFoo(x = 1) - val : J = j - val : Int = .getFoo() - .setFoo(x = .inc()) - /*~> Unit */ + { // BLOCK + val : J = j + val : Int = .getFoo() + .setFoo(x = .inc()) + + } /*~> Unit */ j.setFoo(x = j.getFoo().plus(other = 1)) } diff --git a/compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.fir.ir.txt b/compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.fir.ir.txt index 23d97d53bd3..d4fe8f4ac6d 100644 --- a/compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.fir.ir.txt @@ -8,17 +8,18 @@ FILE fqName: fileName:/javaSyntheticPropertyAccess.kt CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in .J' type=kotlin.Unit origin=EQ $this: GET_VAR 'j: .J declared in .test' type=.J origin=null x: CONST Int type=kotlin.Int value=1 - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.J [val] - GET_VAR 'j: .J declared in .test' type=.J origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] - CALL 'public open fun getFoo (): kotlin.Int declared in .J' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'val tmp_0: .J [val] declared in .test' type=.J origin=null - CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in .J' type=kotlin.Unit origin=EQ - $this: GET_VAR 'val tmp_0: .J [val] declared in .test' type=.J origin=null - x: 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 .test' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'val tmp_1: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null + BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.J [val] + GET_VAR 'j: .J declared in .test' type=.J origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + CALL 'public open fun getFoo (): kotlin.Int declared in .J' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'val tmp_0: .J [val] declared in .test' type=.J origin=null + CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in .J' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val tmp_0: .J [val] declared in .test' type=.J origin=null + x: 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 .test' type=kotlin.Int origin=null + GET_VAR 'val tmp_1: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null CALL 'public open fun setFoo (x: kotlin.Int): kotlin.Unit declared in .J' type=kotlin.Unit origin=EQ $this: GET_VAR 'j: .J declared in .test' type=.J origin=null x: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.fir.kt.txt b/compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.fir.kt.txt index fce2040c4c7..453b5c1a535 100644 --- a/compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.fir.kt.txt @@ -1,9 +1,11 @@ fun test(j: J) { j.getFoo() /*~> Unit */ j.setFoo(x = 1) - val : J = j - val : Int = .getFoo() - .setFoo(x = .inc()) - /*~> Unit */ + { // BLOCK + val : J = j + val : Int = .getFoo() + .setFoo(x = .inc()) + + } /*~> Unit */ j.setFoo(x = j.getFoo().plus(other = 1)) } diff --git a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.ir.txt b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.ir.txt index 83d887d8548..8290d8300a5 100644 --- a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.ir.txt @@ -74,44 +74,42 @@ FILE fqName:test fileName:/safeCallWithIncrementDecrement.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: BLOCK type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:test.C [val] - GET_VAR 'val tmp_1: test.C? [val] declared in test.testProperty' type=test.C? origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY - $receiver: GET_VAR 'val tmp_2: test.C [val] declared in test.testProperty' type=test.C origin=null + $receiver: GET_VAR 'val tmp_1: test.C? [val] declared in test.testProperty' type=test.C? origin=null CALL 'public final fun (value: kotlin.Int): kotlin.Unit declared in test' type=kotlin.Unit origin=EQ - $receiver: GET_VAR 'val tmp_2: test.C [val] declared in test.testProperty' type=test.C origin=null + $receiver: GET_VAR 'val tmp_1: test.C? [val] declared in test.testProperty' type=test.C? origin=null value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_3: kotlin.Int [val] declared in test.testProperty' type=kotlin.Int origin=null - GET_VAR 'val tmp_3: kotlin.Int [val] declared in test.testProperty' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_2: kotlin.Int [val] declared in test.testProperty' type=kotlin.Int origin=null + GET_VAR 'val tmp_2: kotlin.Int [val] declared in test.testProperty' type=kotlin.Int origin=null FUN name:testArrayAccess visibility:public modality:FINAL <> (nc:test.C?) returnType:kotlin.Unit VALUE_PARAMETER name:nc index:0 type:test.C? BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Int? origin=SAFE_CALL - VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:test.C? [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:test.C? [val] GET_VAR 'nc: test.C? declared in test.testArrayAccess' type=test.C? origin=null WHEN type=kotlin.Int? origin=null BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'val tmp_4: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null + arg0: GET_VAR 'val tmp_3: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null arg1: CONST Null type=kotlin.Nothing? value=null then: CONST Null type=kotlin.Nothing? value=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: BLOCK type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val] CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY - $receiver: GET_VAR 'val tmp_4: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.Int [val] + $receiver: GET_VAR 'val tmp_3: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] CONST Int type=kotlin.Int value=0 - VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.Int [val] CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in test' type=kotlin.Int origin=null - $receiver: GET_VAR 'val tmp_5: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null - index: GET_VAR 'val tmp_6: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_4: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + index: GET_VAR 'val tmp_5: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit [operator] declared in test' type=kotlin.Unit origin=null - $receiver: GET_VAR 'val tmp_5: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null - index: GET_VAR 'val tmp_6: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_4: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + index: GET_VAR 'val tmp_5: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_7: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null - GET_VAR 'val tmp_7: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_6: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + GET_VAR 'val tmp_6: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.kt.txt b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.kt.txt index e1d287f4ef8..cd273b21021 100644 --- a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.kt.txt @@ -39,9 +39,8 @@ fun testProperty(nc: C?) { when { EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null else -> { // BLOCK - val : C = tmp1_safe_receiver - val : Int = .() - .(value = .inc()) + val : Int = tmp1_safe_receiver.() + tmp1_safe_receiver.(value = .inc()) } } diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt index 2eff6adc31a..2c6e5553fb2 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.ir.txt @@ -50,7 +50,7 @@ FILE fqName: fileName:/whileDoWhile.kt arg1: CONST Int type=kotlin.Int value=15 BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + body: BLOCK type=kotlin.Int origin=POSTFIX_INCR VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null SET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Unit origin=POSTFIX_INCR diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt index 0791bab07b2..316a1860a0a 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt @@ -24,11 +24,11 @@ fun test() { } while (less(arg0 = x, arg1 = 15)) } { // BLOCK - do// COMPOSITE { - val : Int = x - x = .inc() - - // } while (less(arg0 = x, arg1 = 20)) + do{ // BLOCK + val : Int = x + x = .inc() + + } while (less(arg0 = x, arg1 = 20)) } } diff --git a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt index 2e5167493eb..0be7ace445c 100644 --- a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.ir.txt @@ -543,7 +543,7 @@ FILE fqName: fileName:/ArrayMap.kt BLOCK_BODY BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + body: BLOCK type=kotlin.Int origin=POSTFIX_INCR VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null diff --git a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt index 9dfe8d52f2c..ddedd156142 100644 --- a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt @@ -224,11 +224,11 @@ internal class ArrayMapImpl : ArrayMap { protected override fun computeNext() { { // BLOCK - do// COMPOSITE { - val : Int = .() - .( = .inc()) - - // } while (when { + do{ // BLOCK + val : Int = .() + .( = .inc()) + + } while (when { less(arg0 = .(), arg1 = .().()) -> EQEQ(arg0 = .().get(index = .()), arg1 = null) else -> false }) diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index eb067bcd32c..47da3befb7e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -357,6 +357,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/IncorrectCharacterLiterals.kt"); } + @Test + @TestMetadata("incrementDecrementOnFullyQualified.kt") + public void testIncrementDecrementOnFullyQualified() throws Exception { + runTest("compiler/testData/diagnostics/tests/incrementDecrementOnFullyQualified.kt"); + } + + @Test + @TestMetadata("incrementDecrementOnObject.kt") + public void testIncrementDecrementOnObject() throws Exception { + runTest("compiler/testData/diagnostics/tests/incrementDecrementOnObject.kt"); + } + @Test @TestMetadata("InferNullabilityInThenBlock.kt") public void testInferNullabilityInThenBlock() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 8b296e131c0..4178f5f9856 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -25913,6 +25913,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -46811,12 +46817,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 1525d4f811b..4af285af6e0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -26873,6 +26873,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -49043,12 +49049,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 597f9e3cc7d..aa69ac9b663 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -21801,6 +21801,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { runTest("compiler/testData/codegen/box/intrinsics/rangeFromCollection.kt"); @@ -37903,11 +37908,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { runTest("compiler/testData/codegen/box/statics/inheritedPropertyInClassObject.kt"); diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-decrement-expression/p-5/neg/2.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-decrement-expression/p-5/neg/2.1.fir.kt index 08e69d30681..e2e7cfb2846 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-decrement-expression/p-5/neg/2.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-decrement-expression/p-5/neg/2.1.fir.kt @@ -5,7 +5,7 @@ fun case1() { var a = Case1() - val res: Any? = ++a + val res: Any? = ++a } @@ -22,7 +22,7 @@ class B() {} fun case2() { var a = Case2() - val res: Any? = ++a + val res: Any? = ++a } class Case2() : C() { diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-increment-expression/p-5/neg/2.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-increment-expression/p-5/neg/2.1.fir.kt deleted file mode 100644 index 6ff1bbbd013..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-increment-expression/p-5/neg/2.1.fir.kt +++ /dev/null @@ -1,37 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION -// SKIP_TXT - -// TESTCASE NUMBER: 1 - -fun case1() { - var a = Case1() - val res: Any? = --a -} - - -class Case1() { - - operator fun dec(): B { - TODO() - } -} - -class B() {} - -// TESTCASE NUMBER: 2 - -fun case2() { - var a = Case2() - val res: Any? = --a -} - -class Case2() : C() { - var i = 0 - - operator fun dec(): C { - TODO() - } - -} - -open class C() {} diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-increment-expression/p-5/neg/2.1.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-increment-expression/p-5/neg/2.1.kt index c21e761c536..e9e0a565d48 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-increment-expression/p-5/neg/2.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions/prefix-increment-expression/p-5/neg/2.1.kt @@ -1,5 +1,6 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION // SKIP_TXT +// FIR_IDENTICAL /* * KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 7504964154d..f5be8e77df0 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -20821,6 +20821,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -34723,12 +34729,24 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index 6c3b2bac7f2..f1b25cef5a5 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -20839,6 +20839,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -34909,12 +34915,24 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 4a94051266c..5be13879850 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -20839,6 +20839,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -34909,12 +34915,24 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index 7bb4ea76898..2f673a5d7c3 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -20839,6 +20839,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -34909,12 +34915,24 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java index 61be684af91..a1904b62bae 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java @@ -23762,6 +23762,12 @@ public class K2NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTes runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -38492,12 +38498,24 @@ public class K2NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTes runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index caf60bfaf04..9e21896f68e 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -23540,6 +23540,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @Test + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @Test @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { @@ -38012,12 +38018,24 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @Test + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @Test @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @Test + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @Test @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java index 0a857d0c0fd..b7237451742 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java @@ -18449,6 +18449,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/intrinsics/prefixIncDec.kt"); } + @TestMetadata("prefixIncDecFir.kt") + public void testPrefixIncDecFir() throws Exception { + runTest("compiler/testData/codegen/box/intrinsics/prefixIncDecFir.kt"); + } + @TestMetadata("rangeFromCollection.kt") public void testRangeFromCollection() throws Exception { runTest("compiler/testData/codegen/box/intrinsics/rangeFromCollection.kt"); @@ -31263,11 +31268,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/statics/incInClassObject.kt"); } + @TestMetadata("incInClassObjectFir.kt") + public void testIncInClassObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInClassObjectFir.kt"); + } + @TestMetadata("incInObject.kt") public void testIncInObject() throws Exception { runTest("compiler/testData/codegen/box/statics/incInObject.kt"); } + @TestMetadata("incInObjectFir.kt") + public void testIncInObjectFir() throws Exception { + runTest("compiler/testData/codegen/box/statics/incInObjectFir.kt"); + } + @TestMetadata("inheritedPropertyInClassObject.kt") public void testInheritedPropertyInClassObject() throws Exception { runTest("compiler/testData/codegen/box/statics/inheritedPropertyInClassObject.kt");