[FIR] Fix problem with local classes in anonymous objects
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
digraph innerClassInAnonymousObject_kt {
|
||||
graph [nodesep=3]
|
||||
node [shape=box penwidth=2]
|
||||
edge [penwidth=2]
|
||||
|
||||
subgraph cluster_0 {
|
||||
color=red
|
||||
0 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
2 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
|
||||
1 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
0 -> {2};
|
||||
2 -> {1};
|
||||
|
||||
subgraph cluster_1 {
|
||||
color=red
|
||||
3 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
5 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
|
||||
4 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
3 -> {5};
|
||||
5 -> {4};
|
||||
|
||||
subgraph cluster_2 {
|
||||
color=red
|
||||
6 [label="Enter function foo" style="filled" fillcolor=red];
|
||||
7 [label="Exit function foo" style="filled" fillcolor=red];
|
||||
}
|
||||
6 -> {7};
|
||||
|
||||
subgraph cluster_3 {
|
||||
color=red
|
||||
8 [label="Enter class Nested" style="filled" fillcolor=red];
|
||||
9 [label="Exit class Nested" style="filled" fillcolor=red];
|
||||
}
|
||||
8 -> {9} [color=green];
|
||||
|
||||
subgraph cluster_4 {
|
||||
color=red
|
||||
10 [label="Enter class <anonymous>" style="filled" fillcolor=red];
|
||||
11 [label="Exit class <anonymous>" style="filled" fillcolor=red];
|
||||
}
|
||||
10 -> {11} [color=green];
|
||||
|
||||
subgraph cluster_5 {
|
||||
color=red
|
||||
14 [label="Enter property" style="filled" fillcolor=red];
|
||||
subgraph cluster_6 {
|
||||
color=blue
|
||||
12 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
13 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
}
|
||||
16 [label="Exit anonymous object"];
|
||||
15 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
14 -> {16};
|
||||
14 -> {0 3 6} [color=red];
|
||||
16 -> {15};
|
||||
12 -> {13};
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// !DUMP_CFG
|
||||
|
||||
val x = object {
|
||||
class Nested {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
FILE: innerClassInAnonymousObject.kt
|
||||
public final val x: R|anonymous| = object : R|kotlin/Any| {
|
||||
private[local] constructor(): R|anonymous| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
local final class Nested : R|kotlin/Any| {
|
||||
public[local] constructor(): R|<anonymous>.Nested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public[local] final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get(): R|anonymous|
|
||||
Generated
+5
@@ -702,6 +702,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassInAnonymousObject.kt")
|
||||
public void testInnerClassInAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inplaceLambdaInControlFlowExpressions.kt")
|
||||
public void testInplaceLambdaInControlFlowExpressions() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.kt");
|
||||
|
||||
+5
@@ -702,6 +702,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/cfg/initBlockAndInPlaceLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassInAnonymousObject.kt")
|
||||
public void testInnerClassInAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inplaceLambdaInControlFlowExpressions.kt")
|
||||
public void testInplaceLambdaInControlFlowExpressions() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/cfg/inplaceLambdaInControlFlowExpressions.kt");
|
||||
|
||||
+1
-1
@@ -177,7 +177,7 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
}
|
||||
|
||||
fun exitRegularClass(klass: FirRegularClass): ControlFlowGraph {
|
||||
if (klass.isLocal) return exitLocalClass(klass)
|
||||
if (klass.isLocal && components.container !is FirClass<*>) return exitLocalClass(klass)
|
||||
return graphBuilder.exitClass(klass)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user