mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
[FIR] Don't create union call node for lambda from one when branch and call from condition of another
This commit is contained in:
committed by
teamcityserver
parent
684ef871ee
commit
1d491fdce6
@@ -3069,6 +3069,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("incorrectSmartcastToNothing.kt")
|
||||
public void testIncorrectSmartcastToNothing() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt10240.kt")
|
||||
public void testKt10240() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/kt10240.kt");
|
||||
|
||||
144
compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.dot
vendored
Normal file
144
compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.dot
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
digraph incorrectSmartcastToNothing_kt {
|
||||
graph [nodesep=3]
|
||||
node [shape=box penwidth=2]
|
||||
edge [penwidth=2]
|
||||
|
||||
subgraph cluster_0 {
|
||||
color=red
|
||||
0 [label="Enter property" style="filled" fillcolor=red];
|
||||
1 [label="Const: String(foo)"];
|
||||
2 [label="Function call: R|java/io/File.File|(...)"];
|
||||
3 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
0 -> {1};
|
||||
1 -> {2};
|
||||
2 -> {3};
|
||||
|
||||
subgraph cluster_1 {
|
||||
color=red
|
||||
4 [label="Enter function test" style="filled" fillcolor=red];
|
||||
subgraph cluster_2 {
|
||||
color=blue
|
||||
5 [label="Enter block"];
|
||||
subgraph cluster_3 {
|
||||
color=blue
|
||||
6 [label="Enter when"];
|
||||
subgraph cluster_4 {
|
||||
color=blue
|
||||
7 [label="Enter when branch condition "];
|
||||
8 [label="Access variable R|<local>/cacheExtSetting|"];
|
||||
9 [label="Const: Null(null)"];
|
||||
10 [label="Equality operator =="];
|
||||
11 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_5 {
|
||||
color=blue
|
||||
12 [label="Enter when branch condition "];
|
||||
13 [label="Access variable R|<local>/cacheExtSetting|"];
|
||||
14 [label="Function call: R|<local>/cacheExtSetting|.R|kotlin/text/isBlank|()"];
|
||||
15 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_6 {
|
||||
color=blue
|
||||
16 [label="Enter when branch condition else"];
|
||||
17 [label="Exit when branch condition"];
|
||||
}
|
||||
18 [label="Enter when branch result"];
|
||||
subgraph cluster_7 {
|
||||
color=blue
|
||||
19 [label="Enter block"];
|
||||
20 [label="Access variable R|<local>/cacheExtSetting|"];
|
||||
21 [label="Function call: R|java/io/File.File|(...)"];
|
||||
22 [label="Exit block"];
|
||||
}
|
||||
23 [label="Exit when branch result"];
|
||||
24 [label="Enter when branch result"];
|
||||
subgraph cluster_8 {
|
||||
color=blue
|
||||
25 [label="Enter block"];
|
||||
26 [label="Const: Null(null)"];
|
||||
27 [label="Exit block"];
|
||||
}
|
||||
28 [label="Exit when branch result"];
|
||||
29 [label="Enter when branch result"];
|
||||
subgraph cluster_9 {
|
||||
color=blue
|
||||
30 [label="Enter block"];
|
||||
31 [label="Access variable R|/cache|"];
|
||||
32 [label="Enter safe call"];
|
||||
33 [label="Postponed enter to lambda"];
|
||||
subgraph cluster_10 {
|
||||
color=blue
|
||||
43 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||
subgraph cluster_11 {
|
||||
color=blue
|
||||
44 [label="Enter block"];
|
||||
45 [label="Access variable R|<local>/it|"];
|
||||
46 [label="Const: String(main.kts.compiled.cache)"];
|
||||
47 [label="Function call: R|java/io/File.File|(...)"];
|
||||
48 [label="Exit block"];
|
||||
}
|
||||
49 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||
}
|
||||
34 [label="Postponed exit from lambda"];
|
||||
35 [label="Function call: $subj$.R|kotlin/let|<R|java/io/File|, R|java/io/File|>(...)"];
|
||||
36 [label="Exit safe call"];
|
||||
37 [label="Exit block"];
|
||||
}
|
||||
38 [label="Exit when branch result"];
|
||||
39 [label="Exit when"];
|
||||
}
|
||||
40 [label="Variable declaration: lval cacheBaseDir: R|java/io/File?|"];
|
||||
41 [label="Exit block"];
|
||||
}
|
||||
42 [label="Exit function test" style="filled" fillcolor=red];
|
||||
}
|
||||
4 -> {5};
|
||||
5 -> {6};
|
||||
6 -> {7};
|
||||
7 -> {8};
|
||||
8 -> {9};
|
||||
9 -> {10};
|
||||
10 -> {11};
|
||||
11 -> {29 12};
|
||||
12 -> {13};
|
||||
13 -> {14};
|
||||
14 -> {15};
|
||||
15 -> {24 16};
|
||||
16 -> {17};
|
||||
17 -> {18};
|
||||
18 -> {19};
|
||||
19 -> {20};
|
||||
20 -> {21};
|
||||
21 -> {22};
|
||||
22 -> {23};
|
||||
23 -> {39};
|
||||
24 -> {25};
|
||||
25 -> {26};
|
||||
26 -> {27};
|
||||
27 -> {28};
|
||||
28 -> {39};
|
||||
29 -> {30};
|
||||
30 -> {31};
|
||||
31 -> {32 36};
|
||||
32 -> {33};
|
||||
33 -> {43};
|
||||
33 -> {34} [color=red];
|
||||
33 -> {43} [style=dashed];
|
||||
34 -> {35};
|
||||
35 -> {36};
|
||||
36 -> {37};
|
||||
37 -> {38};
|
||||
38 -> {39};
|
||||
39 -> {40};
|
||||
40 -> {41};
|
||||
41 -> {42};
|
||||
43 -> {44};
|
||||
44 -> {45};
|
||||
45 -> {46};
|
||||
46 -> {47};
|
||||
47 -> {48};
|
||||
48 -> {49};
|
||||
49 -> {34} [color=green];
|
||||
|
||||
}
|
||||
20
compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.fir.txt
vendored
Normal file
20
compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.fir.txt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
FILE: incorrectSmartcastToNothing.kt
|
||||
public final val cache: R|java/io/File?| = R|java/io/File.File|(String(foo))
|
||||
public get(): R|java/io/File?|
|
||||
public final fun test(cacheExtSetting: R|kotlin/String?|): R|kotlin/Unit| {
|
||||
lval cacheBaseDir: R|java/io/File?| = when () {
|
||||
==(R|<local>/cacheExtSetting|, Null(null)) -> {
|
||||
R|/cache|?.{ $subj$.R|kotlin/let|<R|java/io/File|, R|java/io/File|>(<L> = let@fun <anonymous>(it: R|java/io/File|): R|java/io/File| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||
^ R|java/io/File.File|(R|<local>/it|, String(main.kts.compiled.cache))
|
||||
}
|
||||
) }
|
||||
}
|
||||
R|<local>/cacheExtSetting|.R|kotlin/text/isBlank|() -> {
|
||||
Null(null)
|
||||
}
|
||||
else -> {
|
||||
R|java/io/File.File|(R|<local>/cacheExtSetting|)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
15
compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.kt
vendored
Normal file
15
compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.kt
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// WITH_STDLIB
|
||||
// FULL_JDK
|
||||
// DUMP_CFG
|
||||
|
||||
import java.io.File
|
||||
|
||||
val cache: File? = File("foo")
|
||||
|
||||
fun test(cacheExtSetting: String?) {
|
||||
val cacheBaseDir = when {
|
||||
cacheExtSetting == null -> cache?.let { File(it, "main.kts.compiled.cache") }
|
||||
cacheExtSetting.isBlank() -> null
|
||||
else -> File(cacheExtSetting)
|
||||
}
|
||||
}
|
||||
@@ -3467,6 +3467,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incorrectSmartcastToNothing.kt")
|
||||
public void testIncorrectSmartcastToNothing() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt10240.kt")
|
||||
public void testKt10240() throws Exception {
|
||||
|
||||
@@ -3467,6 +3467,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incorrectSmartcastToNothing.kt")
|
||||
public void testIncorrectSmartcastToNothing() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt10240.kt")
|
||||
public void testKt10240() throws Exception {
|
||||
|
||||
@@ -627,6 +627,7 @@ class ControlFlowGraphBuilder {
|
||||
}
|
||||
|
||||
fun enterWhenBranchCondition(whenBranch: FirWhenBranch): WhenBranchConditionEnterNode {
|
||||
levelCounter += whenBranchIndices.top().getValue(whenBranch)
|
||||
return createWhenBranchConditionEnterNode(whenBranch).also { addNewSimpleNode(it) }.also { levelCounter++ }
|
||||
}
|
||||
|
||||
@@ -639,7 +640,6 @@ class ControlFlowGraphBuilder {
|
||||
lastNodes.push(it)
|
||||
addEdge(conditionExitNode, it)
|
||||
}
|
||||
levelCounter += whenBranchIndices.top().getValue(whenBranch)
|
||||
return conditionExitNode to branchEnterNode
|
||||
}
|
||||
|
||||
|
||||
@@ -572,17 +572,17 @@ digraph kt44814_kt {
|
||||
}
|
||||
subgraph cluster_59 {
|
||||
color=blue
|
||||
177 [label="Enter when branch condition [4]"];
|
||||
178 [label="Type operator: ($subj$ is R|FirPsiSourceElement|) [5]"];
|
||||
179 [label="Exit when branch condition [4]"];
|
||||
177 [label="Enter when branch condition [5]"];
|
||||
178 [label="Type operator: ($subj$ is R|FirPsiSourceElement|) [6]"];
|
||||
179 [label="Exit when branch condition [5]"];
|
||||
}
|
||||
subgraph cluster_60 {
|
||||
color=blue
|
||||
180 [label="Enter when branch condition [4]"];
|
||||
181 [label="Type operator: ($subj$ is R|FirLightSourceElement|) [5]"];
|
||||
182 [label="Exit when branch condition [4]"];
|
||||
180 [label="Enter when branch condition [6]"];
|
||||
181 [label="Type operator: ($subj$ is R|FirLightSourceElement|) [7]"];
|
||||
182 [label="Exit when branch condition [6]"];
|
||||
}
|
||||
183 [label="Enter when branch result [5]"];
|
||||
183 [label="Enter when branch result [7]"];
|
||||
subgraph cluster_61 {
|
||||
color=blue
|
||||
184 [label="Enter block [7]"];
|
||||
@@ -623,7 +623,7 @@ digraph kt44814_kt {
|
||||
202 [label="Exit block [7]"];
|
||||
}
|
||||
203 [label="Exit when branch result [6]"];
|
||||
204 [label="Enter when branch result [5]"];
|
||||
204 [label="Enter when branch result [6]"];
|
||||
subgraph cluster_64 {
|
||||
color=blue
|
||||
205 [label="Enter block [6]"];
|
||||
@@ -796,10 +796,10 @@ digraph kt44814_kt {
|
||||
}
|
||||
subgraph cluster_72 {
|
||||
color=blue
|
||||
261 [label="Enter when branch condition else [4]"];
|
||||
262 [label="Exit when branch condition [4]"];
|
||||
261 [label="Enter when branch condition else [5]"];
|
||||
262 [label="Exit when branch condition [5]"];
|
||||
}
|
||||
263 [label="Enter when branch result [5]"];
|
||||
263 [label="Enter when branch result [6]"];
|
||||
subgraph cluster_73 {
|
||||
color=blue
|
||||
264 [label="Enter block [6]"];
|
||||
|
||||
@@ -3467,6 +3467,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/equalsAndIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incorrectSmartcastToNothing.kt")
|
||||
public void testIncorrectSmartcastToNothing() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/incorrectSmartcastToNothing.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt10240.kt")
|
||||
public void testKt10240() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user