diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt index e0203c68e2a..2445647fb60 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt @@ -584,8 +584,11 @@ class ControlFlowGraphBuilder { // ----------------------------------- Property ----------------------------------- + private val FirProperty.hasInitialization: Boolean + get() = initializer != null || delegate != null || hasExplicitBackingField + fun enterProperty(property: FirProperty): PropertyInitializerEnterNode? { - if (property.initializer == null && property.delegate == null && !property.hasExplicitBackingField) return null + if (!property.hasInitialization) return null val graph = ControlFlowGraph(property, "val ${property.name}", ControlFlowGraph.Kind.PropertyInitializer) pushGraph(graph, Mode.PropertyInitializer) @@ -603,7 +606,7 @@ class ControlFlowGraphBuilder { } fun exitProperty(property: FirProperty): Pair? { - if (property.initializer == null && property.delegate == null && !property.hasExplicitBackingField) return null + if (!property.hasInitialization) return null val exitNode = exitTargetsForTry.pop() as PropertyInitializerExitNode popAndAddEdge(exitNode) val graph = popGraph() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index b676eb3f042..d0a3f4d00b8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -135,11 +135,13 @@ open class FirDeclarationsResolveTransformer(transformer: FirAbstractBodyResolve } property.transformReceiverParameter(transformer, ResolutionMode.ContextIndependent) - dataFlowAnalyzer.enterProperty(property) doTransformTypeParameters(property) val shouldResolveEverything = !implicitTypeOnly return withFullBodyResolve { val initializerIsAlreadyResolved = bodyResolveState >= FirPropertyBodyResolveState.INITIALIZER_RESOLVED + if (!initializerIsAlreadyResolved) { + dataFlowAnalyzer.enterProperty(property) + } var backingFieldIsAlreadyResolved = false context.withProperty(property) { context.forPropertyInitializer {