[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 { subgraph cluster_6 {
color=red color=red
26 [label="Enter function foo" style="filled" fillcolor=red]; 26 [label="Enter function foo" style="filled" fillcolor=red];
28 [label="Postponed enter to lambda"];
subgraph cluster_7 { 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 color=blue
33 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; 33 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
35 [label="Access variable R|<local>/a|"]; 35 [label="Access variable R|<local>/a|"];
36 [label="Access variable R|kotlin/String.length|"]; 36 [label="Access variable R|kotlin/String.length|"];
subgraph cluster_8 { subgraph cluster_11 {
color=blue color=blue
37 [label="Enter when"]; 37 [label="Enter when"];
subgraph cluster_9 { subgraph cluster_12 {
color=blue color=blue
39 [label="Enter when branch condition "]; 39 [label="Enter when branch condition "];
40 [label="Access variable R|<local>/b|"]; 40 [label="Access variable R|<local>/b|"];
41 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"]; 41 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"];
42 [label="Exit when branch condition"]; 42 [label="Exit when branch condition"];
} }
subgraph cluster_10 { subgraph cluster_13 {
color=blue color=blue
50 [label="Enter when branch condition else"]; 50 [label="Enter when branch condition else"];
51 [label="Exit when branch condition"]; 51 [label="Exit when branch condition"];
} }
52 [label="Enter when branch result"]; 52 [label="Enter when branch result"];
subgraph cluster_11 { subgraph cluster_14 {
color=blue color=blue
53 [label="Enter block"]; 53 [label="Enter block"];
54 [label="Const: Int(1)"]; 54 [label="Const: Int(1)"];
@@ -110,7 +143,7 @@ digraph localClassesWithImplicit_kt {
} }
56 [label="Exit when branch result"]; 56 [label="Exit when branch result"];
43 [label="Enter when branch result"]; 43 [label="Enter when branch result"];
subgraph cluster_12 { subgraph cluster_15 {
color=blue color=blue
44 [label="Enter block"]; 44 [label="Enter block"];
45 [label="Access variable R|<local>/b|"]; 45 [label="Access variable R|<local>/b|"];
@@ -175,32 +208,6 @@ digraph localClassesWithImplicit_kt {
54 -> {55}; 54 -> {55};
55 -> {56}; 55 -> {56};
56 -> {38}; 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}; 57 -> {59};
59 -> {64}; 59 -> {64};
59 -> {60} [color=red]; 59 -> {60} [color=red];
@@ -217,15 +224,6 @@ digraph localClassesWithImplicit_kt {
68 -> {69}; 68 -> {69};
69 -> {70}; 69 -> {70};
70 -> {65}; 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}; 71 -> {73};
73 -> {74}; 73 -> {74};
74 -> {72}; 74 -> {72};
@@ -281,8 +281,12 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
return regularClass.runAllPhasesForLocalClass(transformer, components, data).compose() return regularClass.runAllPhasesForLocalClass(transformer, components, data).compose()
} }
val notAnalyzed = regularClass.resolvePhase < transformerPhase
return withTypeParametersOf(regularClass) { return withTypeParametersOf(regularClass) {
dataFlowAnalyzer.enterClass() if (notAnalyzed) {
dataFlowAnalyzer.enterClass()
}
val oldConstructorScope = primaryConstructorParametersScope val oldConstructorScope = primaryConstructorParametersScope
val oldContainingClass = containingClass val oldContainingClass = containingClass
primaryConstructorParametersScope = null primaryConstructorParametersScope = null
@@ -299,11 +303,13 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
} }
transformDeclarationContent(regularClass, data).single as FirRegularClass transformDeclarationContent(regularClass, data).single as FirRegularClass
} }
if (!implicitTypeOnly) { if (notAnalyzed) {
val controlFlowGraph = dataFlowAnalyzer.exitRegularClass(result) if (!implicitTypeOnly) {
result.transformControlFlowGraphReference(ControlFlowGraphReferenceTransformer, controlFlowGraph) val controlFlowGraph = dataFlowAnalyzer.exitRegularClass(result)
} else { result.transformControlFlowGraphReference(ControlFlowGraphReferenceTransformer, controlFlowGraph)
dataFlowAnalyzer.exitClass() } else {
dataFlowAnalyzer.exitClass()
}
} }
containingClass = oldContainingClass containingClass = oldContainingClass
primaryConstructorParametersScope = oldConstructorScope primaryConstructorParametersScope = oldConstructorScope