FIR DFA: add a union node for property delegates
The delegate is resolved in context-dependent mode and thus can be an incomplete call; if there is no `provideDelegate` method to complete it, the result is effectively `val x$delegate = y.id()` where `id` is `fun <T> id(x: T) = x`, except we don't get a real node for `id` so the DFA edges from lambdas in `y` go who knows where.
This commit is contained in:
@@ -362,6 +362,14 @@ class PropertyInitializerExitNode(owner: ControlFlowGraph, override val fir: Fir
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DelegateExpressionExitNode(owner: ControlFlowGraph, override val fir: FirExpression, level: Int, id: Int)
|
||||
: CFGNode<FirExpression>(owner, level, id), UnionNodeMarker {
|
||||
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
||||
return visitor.visitDelegateExpressionExitNode(this, data)
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------- Field -----------------------------------
|
||||
|
||||
@OptIn(CfgInternals::class)
|
||||
|
||||
@@ -85,6 +85,7 @@ fun CFGNode<*>.render(): String =
|
||||
is PartOfClassInitializationNode -> "Part of class initialization"
|
||||
is PropertyInitializerEnterNode -> "Enter property"
|
||||
is PropertyInitializerExitNode -> "Exit property"
|
||||
is DelegateExpressionExitNode -> "Exit property delegate"
|
||||
is FieldInitializerEnterNode -> "Enter field"
|
||||
is FieldInitializerExitNode -> "Exit field"
|
||||
is InitBlockEnterNode -> "Enter init block"
|
||||
|
||||
+4
@@ -104,6 +104,10 @@ abstract class ControlFlowGraphVisitor<out R, in D> {
|
||||
return visitNode(node, data)
|
||||
}
|
||||
|
||||
open fun visitDelegateExpressionExitNode(node: DelegateExpressionExitNode, data: D): R {
|
||||
return visitUnionNode(node, data)
|
||||
}
|
||||
|
||||
// ----------------------------------- Field -----------------------------------
|
||||
|
||||
open fun visitFieldInitializerEnterNode(node: FieldInitializerEnterNode, data: D): R {
|
||||
|
||||
+8
@@ -50,6 +50,10 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
||||
visitNode(node)
|
||||
}
|
||||
|
||||
open fun visitDelegateExpressionExitNode(node: DelegateExpressionExitNode) {
|
||||
visitUnionNode(node)
|
||||
}
|
||||
|
||||
// ----------------------------------- Init -----------------------------------
|
||||
|
||||
open fun visitInitBlockEnterNode(node: InitBlockEnterNode) {
|
||||
@@ -339,6 +343,10 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
||||
visitPropertyInitializerExitNode(node)
|
||||
}
|
||||
|
||||
final override fun visitDelegateExpressionExitNode(node: DelegateExpressionExitNode, data: Nothing?) {
|
||||
visitDelegateExpressionExitNode(node)
|
||||
}
|
||||
|
||||
// ----------------------------------- Init -----------------------------------
|
||||
|
||||
final override fun visitInitBlockEnterNode(node: InitBlockEnterNode, data: Nothing?) {
|
||||
|
||||
Reference in New Issue
Block a user