From d70dbbc4cfa42350013c4a1008c8a43aa3601abf Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Fri, 11 Aug 2023 18:17:58 +0900 Subject: [PATCH] [LL API] Resolve properties called inside code fragments 'CodeFragmentCapturedValueAnalyzer' assumes the analyzed code fragment is then passed to the backend. For property calls, there are several code generation strategies (field, accessor, delegate). In order to be able to choose one, the whole property, including its possibly 'const' initializer, must be resolved. The commit fixes a plenty of 'FirIdeNormalAnalysisSourceModuleCompilerF\ acilityTestGenerated.CodeFragments.Capturing' tests that broke after the 'FirExpression.type' refactoring. --- .../api/fir/compile/CodeFragmentCapturedValueAnalyzer.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/compile/CodeFragmentCapturedValueAnalyzer.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/compile/CodeFragmentCapturedValueAnalyzer.kt index 5a80443635a..639d9a11c08 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/compile/CodeFragmentCapturedValueAnalyzer.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/compile/CodeFragmentCapturedValueAnalyzer.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol import org.jetbrains.kotlin.fir.resolve.defaultType import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef @@ -188,6 +189,9 @@ private class CodeFragmentCapturedValueVisitor( else -> CodeFragmentCapturedValue.Local(symbol.name, symbol.isMutated, isCrossingInlineBounds) } register(CodeFragmentCapturedSymbol(capturedValue, symbol, symbol.resolvedReturnTypeRef)) + } else { + // Property call generation depends on complete backing field resolution (Fir2IrLazyProperty.backingField) + symbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE) } } is FirBackingFieldSymbol -> {