[FIR] Let prefix inc/dec call getter twice for compatibility with K1

#KT-57179 Fixed
This commit is contained in:
Kirill Rakhman
2023-03-15 17:24:40 +01:00
committed by Space Team
parent fea344faa4
commit 45d2424ad8
50 changed files with 1391 additions and 794 deletions
@@ -705,9 +705,8 @@ internal class KtFirCallResolver(
val setPartiallyAppliedSymbol = fir.toPartiallyAppliedSymbol(arrayAccessExpression.arrayExpression) ?: return null
return when (incDecPrecedence) {
KtCompoundAccess.IncOrDecOperation.Precedence.PREFIX -> {
// For prefix case, the last argument is a reference to a synthetic local variable `<unary-result>` storing the result. So
// we find the inc or dec operation call from the initializer of this local variable.
val operationCall = getInitializerOfReferencedLocalVariable(lastArg) ?: return null
// For prefix case, the last argument is a call to get(...).inc().
val operationCall = lastArg as? FirFunctionCall ?: return null
val operationPartiallyAppliedSymbol = operationCall.toPartiallyAppliedSymbol(arrayAccessExpression) ?: return null
// The get call is the explicit receiver of this operation call
val getCall = operationCall.explicitReceiver as? FirFunctionCall ?: return null
@@ -711,6 +711,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/PackageQualified.kt");
}
@Test
@TestMetadata("prefixIncReturnType.kt")
public void testPrefixIncReturnType() throws Exception {
runTest("compiler/testData/diagnostics/tests/prefixIncReturnType.kt");
}
@Test
@TestMetadata("prefixIncSmartCast.kt")
public void testPrefixIncSmartCast() throws Exception {
runTest("compiler/testData/diagnostics/tests/prefixIncSmartCast.kt");
}
@Test
@TestMetadata("PrimaryConstructors.kt")
public void testPrimaryConstructors() throws Exception {