FIR DFA: fix mismatched calls to enter/exitProperty
Otherwise the graph stack becomes incorrect.
This commit is contained in:
+5
-2
@@ -584,8 +584,11 @@ class ControlFlowGraphBuilder {
|
|||||||
|
|
||||||
// ----------------------------------- Property -----------------------------------
|
// ----------------------------------- Property -----------------------------------
|
||||||
|
|
||||||
|
private val FirProperty.hasInitialization: Boolean
|
||||||
|
get() = initializer != null || delegate != null || hasExplicitBackingField
|
||||||
|
|
||||||
fun enterProperty(property: FirProperty): PropertyInitializerEnterNode? {
|
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)
|
val graph = ControlFlowGraph(property, "val ${property.name}", ControlFlowGraph.Kind.PropertyInitializer)
|
||||||
pushGraph(graph, Mode.PropertyInitializer)
|
pushGraph(graph, Mode.PropertyInitializer)
|
||||||
@@ -603,7 +606,7 @@ class ControlFlowGraphBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun exitProperty(property: FirProperty): Pair<PropertyInitializerExitNode, ControlFlowGraph>? {
|
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
|
val exitNode = exitTargetsForTry.pop() as PropertyInitializerExitNode
|
||||||
popAndAddEdge(exitNode)
|
popAndAddEdge(exitNode)
|
||||||
val graph = popGraph()
|
val graph = popGraph()
|
||||||
|
|||||||
+3
-1
@@ -135,11 +135,13 @@ open class FirDeclarationsResolveTransformer(transformer: FirAbstractBodyResolve
|
|||||||
}
|
}
|
||||||
|
|
||||||
property.transformReceiverParameter(transformer, ResolutionMode.ContextIndependent)
|
property.transformReceiverParameter(transformer, ResolutionMode.ContextIndependent)
|
||||||
dataFlowAnalyzer.enterProperty(property)
|
|
||||||
doTransformTypeParameters(property)
|
doTransformTypeParameters(property)
|
||||||
val shouldResolveEverything = !implicitTypeOnly
|
val shouldResolveEverything = !implicitTypeOnly
|
||||||
return withFullBodyResolve {
|
return withFullBodyResolve {
|
||||||
val initializerIsAlreadyResolved = bodyResolveState >= FirPropertyBodyResolveState.INITIALIZER_RESOLVED
|
val initializerIsAlreadyResolved = bodyResolveState >= FirPropertyBodyResolveState.INITIALIZER_RESOLVED
|
||||||
|
if (!initializerIsAlreadyResolved) {
|
||||||
|
dataFlowAnalyzer.enterProperty(property)
|
||||||
|
}
|
||||||
var backingFieldIsAlreadyResolved = false
|
var backingFieldIsAlreadyResolved = false
|
||||||
context.withProperty(property) {
|
context.withProperty(property) {
|
||||||
context.forPropertyInitializer {
|
context.forPropertyInitializer {
|
||||||
|
|||||||
Reference in New Issue
Block a user