From b1436804b3d5df22242def1005945990b615bee9 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 4 Feb 2020 11:02:42 +0300 Subject: [PATCH] [FIR, by demiurg] Fix exception in DFA for a case with lambda empty body --- .../fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt | 5 ++++- .../kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt index 56d03fa471d..171f0efa22e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt @@ -19,4 +19,7 @@ class FirControlFlowGraphReferenceImpl(val controlFlowGraph: ControlFlowGraph) : override fun transformChildren(transformer: FirTransformer, data: D): FirControlFlowGraphReference { return this } -} \ No newline at end of file +} + +val FirControlFlowGraphReference.controlFlowGraph: ControlFlowGraph? + get() = (this as? FirControlFlowGraphReferenceImpl)?.controlFlowGraph \ No newline at end of file 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 a3afa752ecb..5d431ee1ee0 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 @@ -173,7 +173,9 @@ class ControlFlowGraphBuilder { is StubNode -> firstPreviousNode.extractArgument() else -> fir.extractArgument() } - return exitsOfAnonymousFunctions.getValue(function).previousNodes.mapNotNull { + + val exitNode = function.controlFlowGraphReference.controlFlowGraph?.exitNode ?: exitsOfAnonymousFunctions.getValue(function) + return exitNode.previousNodes.mapNotNull { it.extractArgument() as FirStatement? } }