FIR DFA: fix mismatched calls to enter/exitProperty

Otherwise the graph stack becomes incorrect.
This commit is contained in:
pyos
2022-12-08 15:48:09 +01:00
committed by Dmitriy Novozhilov
parent bcc54deb64
commit 5180e1f4a4
2 changed files with 8 additions and 3 deletions
@@ -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<PropertyInitializerExitNode, ControlFlowGraph>? {
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()
@@ -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 {