[FE1.0] Fix CFG for inline function calls in finally blocks.

The body of the InlinedLocalFunctionDeclarationInstruction was
not copied. That confuses the information on the exceptional edge
with the information on the normal edge.

^KT-52131 Fixed
This commit is contained in:
Mads Ager
2022-04-25 14:55:04 +02:00
committed by Mikhail Glukhikh
parent 2100afd122
commit 17b5e46547
7 changed files with 39 additions and 2 deletions
@@ -5722,6 +5722,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/kt510.kt");
}
@Test
@TestMetadata("kt52131.kt")
public void testKt52131() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/kt52131.kt");
}
@Test
@TestMetadata("kt607.kt")
public void testKt607() throws Exception {
@@ -5722,6 +5722,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/kt510.kt");
}
@Test
@TestMetadata("kt52131.kt")
public void testKt52131() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/kt52131.kt");
}
@Test
@TestMetadata("kt607.kt")
public void testKt607() throws Exception {
@@ -5722,6 +5722,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/kt510.kt");
}
@Test
@TestMetadata("kt52131.kt")
public void testKt52131() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/kt52131.kt");
}
@Test
@TestMetadata("kt607.kt")
public void testKt607() throws Exception {
@@ -30,11 +30,11 @@ class InlinedLocalFunctionDeclarationInstruction(
blockScope: BlockScope,
val kind: EventOccurrencesRange
) : LocalFunctionDeclarationInstruction(element, body, blockScope) {
override fun createCopy(): InstructionImpl = InlinedLocalFunctionDeclarationInstruction(element, body, blockScope, kind)
override fun createCopy(): InstructionImpl = InlinedLocalFunctionDeclarationInstruction(element, body.copy(), blockScope, kind)
override fun accept(visitor: InstructionVisitor) = visitor.visitInlinedLocalFunctionDeclarationInstruction(this)
override fun <R> accept(visitor: InstructionVisitorWithResult<R>): R = visitor.visitInlinedFunctionDeclarationInstruction(this)
override fun toString(): String = "inlined(${render(element)})"
}
}
@@ -0,0 +1,10 @@
// FIR_IDENTICAL
fun foo(): Int {
var result = 0
try {
} finally {
42.let { }
}
return result
}
@@ -0,0 +1,3 @@
package
public fun foo(): kotlin.Int
@@ -5728,6 +5728,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/kt510.kt");
}
@Test
@TestMetadata("kt52131.kt")
public void testKt52131() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/kt52131.kt");
}
@Test
@TestMetadata("kt607.kt")
public void testKt607() throws Exception {