[LL FIR] KTIJ-24895 Record compound assignments with error names

- If the callee reference in a desugared compound assignment was an
  error reference, the compound assignment wasn't cached by
  `FirElementsRecorder`. This led to KTIJ-24895 (see the issue for more
  details).
- The solution falls back on the compound assignment's source to decide
  `isSourceForCompoundAccess`, as an operation name can be reconstructed
  from the PSI.

^KTIJ-24895 fixed
This commit is contained in:
Marco Pennekamp
2023-03-20 18:02:29 +01:00
committed by Space Team
parent d14a55d775
commit 9a3eece944
2 changed files with 32 additions and 5 deletions
@@ -34,8 +34,14 @@ import org.jetbrains.kotlin.fir.references.builder.buildDelegateFieldReference
import org.jetbrains.kotlin.fir.references.builder.buildImplicitThisReference
import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.ConeStarProjection
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
import org.jetbrains.kotlin.fir.types.impl.*
import org.jetbrains.kotlin.lexer.KtTokens
@@ -141,6 +147,9 @@ fun IElementType.toUnaryName(): Name? {
}
fun IElementType.toFirOperation(): FirOperation =
toFirOperationOrNull() ?: error("Cannot convert element type to FIR operation: $this")
fun IElementType.toFirOperationOrNull(): FirOperation? =
when (this) {
KtTokens.LT -> FirOperation.LT
KtTokens.GT -> FirOperation.GT
@@ -161,7 +170,7 @@ fun IElementType.toFirOperation(): FirOperation =
KtTokens.AS_KEYWORD -> FirOperation.AS
KtTokens.AS_SAFE -> FirOperation.SAFE_AS
else -> throw AssertionError(this.toString())
else -> null
}
fun FirExpression.generateNotNullOrOther(