[FIR] Don't analyze with DFA already analyzed classes

This commit is contained in:
Dmitriy Novozhilov
2020-04-02 12:25:53 +03:00
parent 0b2536199b
commit 7dd91df10b
2 changed files with 51 additions and 47 deletions
@@ -80,29 +80,62 @@ digraph localClassesWithImplicit_kt {
subgraph cluster_6 {
color=red
26 [label="Enter function foo" style="filled" fillcolor=red];
28 [label="Postponed enter to lambda"];
subgraph cluster_7 {
color=blue
71 [label="Enter function baz" style="filled" fillcolor=red];
73 [label="Const: Int(1)"];
74 [label="Jump: ^baz Int(1)"];
75 [label="Stub" style="filled" fillcolor=gray];
72 [label="Exit function baz" style="filled" fillcolor=red];
}
subgraph cluster_8 {
color=blue
57 [label="Enter function bar" style="filled" fillcolor=red];
59 [label="Postponed enter to lambda"];
subgraph cluster_9 {
color=blue
64 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
66 [label="Access variable R|<local>/b|"];
67 [label="Access variable <Unresolved name: length>#"];
68 [label="Access variable R|<local>/a|"];
69 [label="Access variable R|kotlin/String.length|"];
70 [label="Function call: this@R|/A|.R|/A.baz|()"];
65 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
60 [label="Postponed exit from lambda"];
61 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
62 [label="Jump: ^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <kind=UNKNOWN> {
R|<local>/b|.<Unresolved name: length>#
R|<local>/a|.R|kotlin/String.length|
^ this@R|/A|.R|/A.baz|()
}
)"];
63 [label="Stub" style="filled" fillcolor=gray];
58 [label="Exit function bar" style="filled" fillcolor=red];
}
28 [label="Postponed enter to lambda"];
subgraph cluster_10 {
color=blue
33 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
35 [label="Access variable R|<local>/a|"];
36 [label="Access variable R|kotlin/String.length|"];
subgraph cluster_8 {
subgraph cluster_11 {
color=blue
37 [label="Enter when"];
subgraph cluster_9 {
subgraph cluster_12 {
color=blue
39 [label="Enter when branch condition "];
40 [label="Access variable R|<local>/b|"];
41 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"];
42 [label="Exit when branch condition"];
}
subgraph cluster_10 {
subgraph cluster_13 {
color=blue
50 [label="Enter when branch condition else"];
51 [label="Exit when branch condition"];
}
52 [label="Enter when branch result"];
subgraph cluster_11 {
subgraph cluster_14 {
color=blue
53 [label="Enter block"];
54 [label="Const: Int(1)"];
@@ -110,7 +143,7 @@ digraph localClassesWithImplicit_kt {
}
56 [label="Exit when branch result"];
43 [label="Enter when branch result"];
subgraph cluster_12 {
subgraph cluster_15 {
color=blue
44 [label="Enter block"];
45 [label="Access variable R|<local>/b|"];
@@ -175,32 +208,6 @@ digraph localClassesWithImplicit_kt {
54 -> {55};
55 -> {56};
56 -> {38};
subgraph cluster_13 {
color=red
57 [label="Enter function bar" style="filled" fillcolor=red];
59 [label="Postponed enter to lambda"];
subgraph cluster_14 {
color=blue
64 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
66 [label="Access variable R|<local>/b|"];
67 [label="Access variable <Unresolved name: length>#"];
68 [label="Access variable R|<local>/a|"];
69 [label="Access variable R|kotlin/String.length|"];
70 [label="Function call: this@R|/A|.R|/A.baz|()"];
65 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
60 [label="Postponed exit from lambda"];
61 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
62 [label="Jump: ^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <kind=UNKNOWN> {
R|<local>/b|.<Unresolved name: length>#
R|<local>/a|.R|kotlin/String.length|
^ this@R|/A|.R|/A.baz|()
}
)"];
63 [label="Stub" style="filled" fillcolor=gray];
58 [label="Exit function bar" style="filled" fillcolor=red];
}
57 -> {59};
59 -> {64};
59 -> {60} [color=red];
@@ -217,15 +224,6 @@ digraph localClassesWithImplicit_kt {
68 -> {69};
69 -> {70};
70 -> {65};
subgraph cluster_15 {
color=red
71 [label="Enter function baz" style="filled" fillcolor=red];
73 [label="Const: Int(1)"];
74 [label="Jump: ^baz Int(1)"];
75 [label="Stub" style="filled" fillcolor=gray];
72 [label="Exit function baz" style="filled" fillcolor=red];
}
71 -> {73};
73 -> {74};
74 -> {72};
@@ -281,8 +281,12 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
return regularClass.runAllPhasesForLocalClass(transformer, components, data).compose()
}
val notAnalyzed = regularClass.resolvePhase < transformerPhase
return withTypeParametersOf(regularClass) {
dataFlowAnalyzer.enterClass()
if (notAnalyzed) {
dataFlowAnalyzer.enterClass()
}
val oldConstructorScope = primaryConstructorParametersScope
val oldContainingClass = containingClass
primaryConstructorParametersScope = null
@@ -299,11 +303,13 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
}
transformDeclarationContent(regularClass, data).single as FirRegularClass
}
if (!implicitTypeOnly) {
val controlFlowGraph = dataFlowAnalyzer.exitRegularClass(result)
result.transformControlFlowGraphReference(ControlFlowGraphReferenceTransformer, controlFlowGraph)
} else {
dataFlowAnalyzer.exitClass()
if (notAnalyzed) {
if (!implicitTypeOnly) {
val controlFlowGraph = dataFlowAnalyzer.exitRegularClass(result)
result.transformControlFlowGraphReference(ControlFlowGraphReferenceTransformer, controlFlowGraph)
} else {
dataFlowAnalyzer.exitClass()
}
}
containingClass = oldContainingClass
primaryConstructorParametersScope = oldConstructorScope