[FIR-TEST] Move analysis tests to separate module

This commit is contained in:
Dmitriy Novozhilov
2020-03-18 15:10:46 +03:00
parent 3a479d5d16
commit cc07ae96b3
1477 changed files with 1001 additions and 980 deletions
@@ -0,0 +1,295 @@
digraph callsInPlace_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function test" style="filled" fillcolor=red];
1 [label="Variable declaration: lval x: R|kotlin/Int|"];
2 [label="Postponed enter to lambda"];
subgraph cluster_1 {
color=blue
3 [label="Enter function anonymousFunction"];
4 [label="Const: Int(1)"];
5 [label="Assignmenet: R|<local>/x|"];
6 [label="Exit function anonymousFunction"];
}
7 [label="Call arguments union" style="filled" fillcolor=yellow];
8 [label="Postponed exit from lambda"];
9 [label="Function call: R|kotlin/run|<R|kotlin/Unit|>(...)"];
10 [label="Access variable R|<local>/x|"];
11 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
12 [label="Exit function test" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
2 -> {8} [color=red];
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {8} [color=green];
6 -> {7} [color=red];
7 -> {9} [color=red];
8 -> {9} [color=green];
9 -> {10};
10 -> {11};
11 -> {12};
subgraph cluster_2 {
color=red
13 [label="Enter function test_2" style="filled" fillcolor=red];
14 [label="Const: Int(10)"];
15 [label="Postponed enter to lambda"];
subgraph cluster_3 {
color=blue
16 [label="Enter function anonymousFunction"];
17 [label="Const: String(test_2)"];
18 [label="Exit function anonymousFunction"];
}
19 [label="Postponed exit from lambda"];
20 [label="Function call: R|kotlin/repeat|(...)"];
21 [label="Exit function test_2" style="filled" fillcolor=red];
}
13 -> {14};
14 -> {15};
15 -> {16};
15 -> {19} [color=red];
16 -> {18 17};
17 -> {18};
18 -> {16};
18 -> {19} [color=green];
19 -> {20};
20 -> {21};
subgraph cluster_4 {
color=red
22 [label="Enter function test_3" style="filled" fillcolor=red];
23 [label="Postponed enter to lambda"];
subgraph cluster_5 {
color=blue
24 [label="Enter function anonymousFunction"];
25 [label="Const: String(test_3)"];
26 [label="Exit function anonymousFunction"];
}
27 [label="Postponed exit from lambda"];
28 [label="Const: Int(10)"];
29 [label="Function call: R|kotlin/repeat|(...)"];
30 [label="Exit function test_3" style="filled" fillcolor=red];
}
22 -> {23};
23 -> {24};
23 -> {27} [color=red];
24 -> {26 25};
25 -> {26};
26 -> {24};
26 -> {27} [color=green];
27 -> {28};
28 -> {29};
29 -> {30};
subgraph cluster_6 {
color=red
31 [label="Enter function test_4" style="filled" fillcolor=red];
32 [label="Const: Int(1)"];
33 [label="Postponed enter to lambda"];
subgraph cluster_7 {
color=blue
34 [label="Enter function anonymousFunction"];
35 [label="Const: String(test_4)"];
36 [label="Access variable R|<local>/it|"];
37 [label="Const: Int(0)"];
38 [label="Function call: R|<local>/it|.R|kotlin/Int.compareTo|(...)"];
39 [label="Comparison >"];
40 [label="Exit function anonymousFunction"];
}
41 [label="Call arguments union" style="filled" fillcolor=yellow];
42 [label="Postponed exit from lambda"];
43 [label="Function call: Int(1).R|kotlin/takeUnless|<R|kotlin/Int|>(...)"];
44 [label="Exit function test_4" style="filled" fillcolor=red];
}
31 -> {32};
32 -> {33};
33 -> {34};
33 -> {42} [color=red];
34 -> {35};
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {42} [color=green];
40 -> {41} [color=red];
41 -> {43} [color=red];
42 -> {43} [color=green];
43 -> {44};
subgraph cluster_8 {
color=red
45 [label="Enter function test_5" style="filled" fillcolor=red];
46 [label="Const: Int(1)"];
47 [label="Postponed enter to lambda"];
subgraph cluster_9 {
color=blue
48 [label="Enter function anonymousFunction"];
49 [label="Const: String(test_5)"];
50 [label="Access variable R|<local>/it|"];
51 [label="Const: Int(0)"];
52 [label="Function call: R|<local>/it|.R|kotlin/Int.compareTo|(...)"];
53 [label="Comparison >"];
54 [label="Exit function anonymousFunction"];
}
55 [label="Call arguments union" style="filled" fillcolor=yellow];
56 [label="Postponed exit from lambda"];
57 [label="Function call: Int(1).R|kotlin/takeUnless|<R|kotlin/Int|>(...)"];
58 [label="Exit function test_5" style="filled" fillcolor=red];
}
45 -> {46};
46 -> {47};
47 -> {48};
47 -> {56} [color=red];
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {56} [color=green];
54 -> {55} [color=red];
55 -> {57} [color=red];
56 -> {57} [color=green];
57 -> {58};
subgraph cluster_10 {
color=red
59 [label="Enter function myRun" style="filled" fillcolor=red];
60 [label="Function call: R|<local>/block1|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
61 [label="Function call: R|<local>/block2|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
62 [label="Exit function myRun" style="filled" fillcolor=red];
}
59 -> {60};
60 -> {61};
61 -> {62};
subgraph cluster_11 {
color=red
63 [label="Enter function test_6" style="filled" fillcolor=red];
64 [label="Postponed enter to lambda"];
subgraph cluster_12 {
color=blue
65 [label="Enter function anonymousFunction"];
66 [label="Const: String(test_6_1)"];
67 [label="Exit function anonymousFunction"];
}
68 [label="Postponed exit from lambda"];
69 [label="Postponed enter to lambda"];
subgraph cluster_13 {
color=blue
70 [label="Enter function anonymousFunction"];
71 [label="Const: String(test_6_2)"];
72 [label="Exit function anonymousFunction"];
}
73 [label="Postponed exit from lambda"];
74 [label="Function call: R|/myRun|(...)"];
75 [label="Exit function test_6" style="filled" fillcolor=red];
}
63 -> {64};
64 -> {65};
64 -> {68} [color=red];
65 -> {67 66};
66 -> {67};
67 -> {65};
67 -> {68} [color=green];
68 -> {69};
69 -> {70};
69 -> {73} [color=red];
70 -> {72 71};
71 -> {72};
72 -> {70};
72 -> {73} [color=green];
73 -> {74};
74 -> {75};
subgraph cluster_14 {
color=red
76 [label="Enter function test_7" style="filled" fillcolor=red];
77 [label="Postponed enter to lambda"];
subgraph cluster_15 {
color=blue
78 [label="Enter function anonymousFunction"];
79 [label="Const: String(test_7_2)"];
80 [label="Exit function anonymousFunction"];
}
81 [label="Postponed exit from lambda"];
82 [label="Postponed enter to lambda"];
subgraph cluster_16 {
color=blue
83 [label="Enter function anonymousFunction"];
84 [label="Const: String(test_7_1)"];
85 [label="Exit function anonymousFunction"];
}
86 [label="Postponed exit from lambda"];
87 [label="Function call: R|/myRun|(...)"];
88 [label="Exit function test_7" style="filled" fillcolor=red];
}
76 -> {77};
77 -> {78};
77 -> {81} [color=red];
78 -> {80 79};
79 -> {80};
80 -> {78};
80 -> {81} [color=green];
81 -> {82};
82 -> {83};
82 -> {86} [color=red];
83 -> {85 84};
84 -> {85};
85 -> {83};
85 -> {86} [color=green];
86 -> {87};
87 -> {88};
subgraph cluster_17 {
color=red
89 [label="Enter function myDummyRun" style="filled" fillcolor=red];
90 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
91 [label="Exit function myDummyRun" style="filled" fillcolor=red];
}
89 -> {90};
90 -> {91};
subgraph cluster_18 {
color=red
92 [label="Enter function test_8" style="filled" fillcolor=red];
93 [label="Postponed enter to lambda"];
94 [label="Postponed exit from lambda"];
95 [label="Function call: R|/myDummyRun|(...)"];
96 [label="Exit function test_8" style="filled" fillcolor=red];
}
92 -> {93};
93 -> {94 94} [color=green];
94 -> {95};
95 -> {96};
subgraph cluster_19 {
color=red
97 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
98 [label="Const: String(test_8)"];
99 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
97 -> {98};
98 -> {99};
}
@@ -0,0 +1,53 @@
// !DUMP_CFG
fun test() {
val x: Int
run {
x = 1
}
x.inc()
}
fun test_2() {
repeat(10) {
"test_2"
}
}
fun test_3() {
repeat(action = { "test_3" }, times = 10)
}
fun test_4() {
1.takeUnless {
"test_4"
it > 0
}
}
fun test_5() {
1.takeUnless(predicate = {
"test_5"
it > 0
})
}
inline fun myRun(block1: () -> Unit, block2: () -> Unit) {
block1()
block2()
}
fun test_6() {
myRun({ "test_6_1" }) { "test_6_2" }
}
fun test_7() {
myRun(block2 = { "test_7_2" }, block1 = { "test_7_1" })
}
fun myDummyRun(block: () -> Unit) {
block()
}
fun test_8() {
myDummyRun { "test_8" }
}
@@ -0,0 +1,66 @@
FILE: callsInPlace.kt
public final fun test(): R|kotlin/Unit| {
lval x: R|kotlin/Int|
R|kotlin/run|<R|kotlin/Unit|>(<L> = run@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
R|<local>/x| = Int(1)
}
)
R|<local>/x|.R|kotlin/Int.inc|()
}
public final fun test_2(): R|kotlin/Unit| {
R|kotlin/repeat|(Int(10), <L> = repeat@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Unit| <kind=UNKNOWN> {
^ String(test_2)
}
)
}
public final fun test_3(): R|kotlin/Unit| {
R|kotlin/repeat|(action = repeat@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Unit| <kind=UNKNOWN> {
^ String(test_3)
}
, times = Int(10))
}
public final fun test_4(): R|kotlin/Unit| {
Int(1).R|kotlin/takeUnless|<R|kotlin/Int|>(<L> = takeUnless@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Boolean| <kind=EXACTLY_ONCE> {
String(test_4)
^ CMP(>, R|<local>/it|.R|kotlin/Int.compareTo|(Int(0)))
}
)
}
public final fun test_5(): R|kotlin/Unit| {
Int(1).R|kotlin/takeUnless|<R|kotlin/Int|>(predicate = takeUnless@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Boolean| <kind=EXACTLY_ONCE> {
String(test_5)
^ CMP(>, R|<local>/it|.R|kotlin/Int.compareTo|(Int(0)))
}
)
}
public final inline fun myRun(block1: R|() -> kotlin/Unit|, block2: R|() -> kotlin/Unit|): R|kotlin/Unit| {
R|<local>/block1|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
R|<local>/block2|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun test_6(): R|kotlin/Unit| {
R|/myRun|(myRun@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
^ String(test_6_1)
}
, <L> = myRun@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
^ String(test_6_2)
}
)
}
public final fun test_7(): R|kotlin/Unit| {
R|/myRun|(block2 = myRun@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
^ String(test_7_2)
}
, block1 = myRun@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
^ String(test_7_1)
}
)
}
public final fun myDummyRun(block: R|() -> kotlin/Unit|): R|kotlin/Unit| {
R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
public final fun test_8(): R|kotlin/Unit| {
R|/myDummyRun|(<L> = myDummyRun@fun <anonymous>(): R|kotlin/Unit| {
^ String(test_8)
}
)
}
@@ -0,0 +1,345 @@
digraph conditionalEffects_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function test_1" style="filled" fillcolor=red];
1 [label="Access variable R|<local>/x|"];
2 [label="Type operator: (R|<local>/x| is R|kotlin/Int|)"];
3 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_1 {
color=blue
4 [label="Enter contract"];
5 [label="Access variable R|<local>/x|"];
6 [label="Type operator: (R|<local>/x| is R|kotlin/Int|)"];
7 [label="Exit contract"];
}
8 [label="Access variable R|<local>/x|"];
9 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
10 [label="Exit function test_1" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {10};
subgraph cluster_2 {
color=red
11 [label="Enter function test_2" style="filled" fillcolor=red];
12 [label="Access variable R|<local>/x|"];
13 [label="Function call: R|kotlin/requireNotNull|<R|kotlin/String|>(...)"];
subgraph cluster_3 {
color=blue
14 [label="Enter contract"];
15 [label="Access variable R|<local>/x|"];
16 [label="Const: Null(null)"];
17 [label="Operator !="];
18 [label="Exit contract"];
}
19 [label="Access variable R|<local>/x|"];
20 [label="Access variable R|kotlin/String.length|"];
21 [label="Exit function test_2" style="filled" fillcolor=red];
}
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
16 -> {17};
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
subgraph cluster_4 {
color=red
22 [label="Enter function test_3" style="filled" fillcolor=red];
23 [label="Access variable R|<local>/x|"];
24 [label="Const: Null(null)"];
25 [label="Operator !="];
26 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_5 {
color=blue
27 [label="Enter contract"];
28 [label="Access variable R|<local>/x|"];
29 [label="Const: Null(null)"];
30 [label="Operator !="];
31 [label="Exit contract"];
}
32 [label="Access variable R|<local>/x|"];
33 [label="Access variable R|kotlin/String.length|"];
34 [label="Exit function test_3" style="filled" fillcolor=red];
}
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
subgraph cluster_6 {
color=red
35 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
36 [label="Enter &&"];
37 [label="Access variable R|<local>/x|"];
38 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
39 [label="Exit left part of &&"];
40 [label="Enter right part of &&"];
41 [label="Access variable R|<local>/y|"];
42 [label="Const: Null(null)"];
43 [label="Operator !="];
44 [label="Exit &&"];
}
45 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_8 {
color=blue
46 [label="Enter contract"];
subgraph cluster_9 {
color=blue
47 [label="Enter &&"];
48 [label="Access variable R|<local>/x|"];
49 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
50 [label="Exit left part of &&"];
51 [label="Enter right part of &&"];
52 [label="Access variable R|<local>/y|"];
53 [label="Const: Null(null)"];
54 [label="Operator !="];
55 [label="Exit &&"];
}
56 [label="Exit contract"];
}
57 [label="Access variable R|<local>/x|"];
58 [label="Access variable R|kotlin/String.length|"];
59 [label="Access variable R|<local>/y|"];
60 [label="Access variable R|kotlin/String.length|"];
61 [label="Exit function test_4" style="filled" fillcolor=red];
}
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {44 40};
40 -> {41};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {55 51};
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61};
subgraph cluster_10 {
color=red
62 [label="Enter function test_5" style="filled" fillcolor=red];
subgraph cluster_11 {
color=blue
63 [label="Enter when"];
subgraph cluster_12 {
color=blue
64 [label="Enter when branch condition "];
65 [label="Access variable R|<local>/b|"];
66 [label="Exit when branch condition"];
}
subgraph cluster_13 {
color=blue
67 [label="Enter when branch condition else"];
68 [label="Exit when branch condition"];
}
69 [label="Enter when branch result"];
subgraph cluster_14 {
color=blue
70 [label="Enter block"];
71 [label="Access variable R|<local>/x|"];
72 [label="Access variable <Unresolved name: length>#"];
73 [label="Exit block"];
}
74 [label="Exit when branch result"];
75 [label="Enter when branch result"];
subgraph cluster_15 {
color=blue
76 [label="Enter block"];
77 [label="Access variable R|<local>/x|"];
78 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
79 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_16 {
color=blue
80 [label="Enter contract"];
81 [label="Access variable R|<local>/x|"];
82 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
83 [label="Exit contract"];
}
84 [label="Access variable R|<local>/x|"];
85 [label="Access variable R|kotlin/String.length|"];
86 [label="Exit block"];
}
87 [label="Exit when branch result"];
88 [label="Exit when"];
}
89 [label="Access variable R|<local>/x|"];
90 [label="Access variable <Unresolved name: length>#"];
91 [label="Exit function test_5" style="filled" fillcolor=red];
}
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {75 67};
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {88};
75 -> {76};
76 -> {77};
77 -> {78};
78 -> {79};
79 -> {80};
80 -> {81};
81 -> {82};
82 -> {83};
83 -> {84};
84 -> {85};
85 -> {86};
86 -> {87};
87 -> {88};
88 -> {89};
89 -> {90};
90 -> {91};
subgraph cluster_17 {
color=red
92 [label="Enter function test_6" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
93 [label="Enter when"];
subgraph cluster_19 {
color=blue
94 [label="Enter when branch condition "];
95 [label="Access variable R|<local>/b|"];
96 [label="Exit when branch condition"];
}
subgraph cluster_20 {
color=blue
97 [label="Enter when branch condition else"];
98 [label="Exit when branch condition"];
}
99 [label="Enter when branch result"];
subgraph cluster_21 {
color=blue
100 [label="Enter block"];
101 [label="Access variable R|<local>/x|"];
102 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
103 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_22 {
color=blue
104 [label="Enter contract"];
105 [label="Access variable R|<local>/x|"];
106 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
107 [label="Exit contract"];
}
108 [label="Access variable R|<local>/x|"];
109 [label="Access variable R|kotlin/String.length|"];
110 [label="Exit block"];
}
111 [label="Exit when branch result"];
112 [label="Enter when branch result"];
subgraph cluster_23 {
color=blue
113 [label="Enter block"];
114 [label="Access variable R|<local>/x|"];
115 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
116 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_24 {
color=blue
117 [label="Enter contract"];
118 [label="Access variable R|<local>/x|"];
119 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
120 [label="Exit contract"];
}
121 [label="Access variable R|<local>/x|"];
122 [label="Access variable R|kotlin/String.length|"];
123 [label="Exit block"];
}
124 [label="Exit when branch result"];
125 [label="Exit when"];
}
126 [label="Access variable R|<local>/x|"];
127 [label="Access variable R|kotlin/String.length|"];
128 [label="Exit function test_6" style="filled" fillcolor=red];
}
92 -> {93};
93 -> {94};
94 -> {95};
95 -> {96};
96 -> {112 97};
97 -> {98};
98 -> {99};
99 -> {100};
100 -> {101};
101 -> {102};
102 -> {103};
103 -> {104};
104 -> {105};
105 -> {106};
106 -> {107};
107 -> {108};
108 -> {109};
109 -> {110};
110 -> {111};
111 -> {125};
112 -> {113};
113 -> {114};
114 -> {115};
115 -> {116};
116 -> {117};
117 -> {118};
118 -> {119};
119 -> {120};
120 -> {121};
121 -> {122};
122 -> {123};
123 -> {124};
124 -> {125};
125 -> {126};
126 -> {127};
127 -> {128};
}
@@ -0,0 +1,42 @@
// !DUMP_CFG
fun test_1(x: Any) {
require(x is Int)
x.inc()
}
fun test_2(x: String?) {
requireNotNull(x)
x.length
}
fun test_3(x: String?) {
require(x != null)
x.length
}
fun test_4(x: Any, y: String?) {
require(x is String && y != null)
x.length
y.length
}
fun test_5(x: Any, b: Boolean) {
if (b) {
require(x is String)
x.length
} else {
x.<!UNRESOLVED_REFERENCE!>length<!>
}
x.<!UNRESOLVED_REFERENCE!>length<!>
}
fun test_6(x: Any, b: Boolean) {
if (b) {
require(x is String)
x.length
} else {
require(x is String)
x.length
}
x.length
}
@@ -0,0 +1,45 @@
FILE: conditionalEffects.kt
public final fun test_1(x: R|kotlin/Any|): R|kotlin/Unit| {
R|kotlin/require|((R|<local>/x| is R|kotlin/Int|))
R|<local>/x|.R|kotlin/Int.inc|()
}
public final fun test_2(x: R|kotlin/String?|): R|kotlin/Unit| {
R|kotlin/requireNotNull|<R|kotlin/String|>(R|<local>/x|)
R|<local>/x|.R|kotlin/String.length|
}
public final fun test_3(x: R|kotlin/String?|): R|kotlin/Unit| {
R|kotlin/require|(!=(R|<local>/x|, Null(null)))
R|<local>/x|.R|kotlin/String.length|
}
public final fun test_4(x: R|kotlin/Any|, y: R|kotlin/String?|): R|kotlin/Unit| {
R|kotlin/require|((R|<local>/x| is R|kotlin/String|) && !=(R|<local>/y|, Null(null)))
R|<local>/x|.R|kotlin/String.length|
R|<local>/y|.R|kotlin/String.length|
}
public final fun test_5(x: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| -> {
R|kotlin/require|((R|<local>/x| is R|kotlin/String|))
R|<local>/x|.R|kotlin/String.length|
}
else -> {
R|<local>/x|.<Unresolved name: length>#
}
}
R|<local>/x|.<Unresolved name: length>#
}
public final fun test_6(x: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| -> {
R|kotlin/require|((R|<local>/x| is R|kotlin/String|))
R|<local>/x|.R|kotlin/String.length|
}
else -> {
R|kotlin/require|((R|<local>/x| is R|kotlin/String|))
R|<local>/x|.R|kotlin/String.length|
}
}
R|<local>/x|.R|kotlin/String.length|
}
@@ -0,0 +1,14 @@
fun test_1(s: String?) {
when {
!s.isNullOrEmpty() -> s.length // Should be OK
}
}
fun test_2(s: String?) {
// contracts related
if (s.isNullOrEmpty()) {
s.<!INAPPLICABLE_CANDIDATE!>length<!> // Should be bad
} else {
s.length // Should be OK
}
}
@@ -0,0 +1,20 @@
FILE: notIsNullOrEmpty.kt
public final fun test_1(s: R|kotlin/String?|): R|kotlin/Unit| {
when () {
R|<local>/s|.R|kotlin/text/isNullOrEmpty|().R|kotlin/Boolean.not|() -> {
R|<local>/s|.R|kotlin/String.length|
}
}
}
public final fun test_2(s: R|kotlin/String?|): R|kotlin/Unit| {
when () {
R|<local>/s|.R|kotlin/text/isNullOrEmpty|() -> {
R|<local>/s|.<Inapplicable(WRONG_RECEIVER): [kotlin/String.length]>#
}
else -> {
R|<local>/s|.R|kotlin/String.length|
}
}
}