[FIR-TEST] Move existing contract tests to fromLibrary directory

This commit is contained in:
Dmitriy Novozhilov
2020-04-10 14:43:53 +03:00
parent ba35c43fe9
commit 3c33ee9c68
9 changed files with 24 additions and 11 deletions
@@ -0,0 +1,284 @@
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];
2 [label="Variable declaration: lval x: R|kotlin/Int|"];
3 [label="Postponed enter to lambda"];
subgraph cluster_1 {
color=blue
9 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
11 [label="Const: Int(1)"];
12 [label="Assignment: R|<local>/x|"];
10 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
6 [label="Call arguments union" style="filled" fillcolor=yellow];
4 [label="Postponed exit from lambda"];
5 [label="Function call: R|kotlin/run|<R|kotlin/Unit|>(...)"];
7 [label="Access variable R|<local>/x|"];
8 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
1 [label="Exit function test" style="filled" fillcolor=red];
}
0 -> {2};
2 -> {3};
3 -> {9};
3 -> {4} [color=red];
4 -> {5} [color=green];
5 -> {7};
6 -> {5} [color=red];
7 -> {8};
8 -> {1};
9 -> {11};
10 -> {4} [color=green];
10 -> {6} [color=red];
11 -> {12};
12 -> {10};
subgraph cluster_2 {
color=red
13 [label="Enter function test_2" style="filled" fillcolor=red];
15 [label="Const: Int(10)"];
16 [label="Postponed enter to lambda"];
subgraph cluster_3 {
color=blue
19 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
21 [label="Const: String(test_2)"];
20 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
17 [label="Postponed exit from lambda"];
18 [label="Function call: R|kotlin/repeat|(...)"];
14 [label="Exit function test_2" style="filled" fillcolor=red];
}
13 -> {15};
15 -> {16};
16 -> {19};
16 -> {17} [color=red];
17 -> {18};
18 -> {14};
19 -> {20 21};
20 -> {19};
20 -> {17} [color=green];
21 -> {20};
subgraph cluster_4 {
color=red
22 [label="Enter function test_3" style="filled" fillcolor=red];
24 [label="Postponed enter to lambda"];
subgraph cluster_5 {
color=blue
28 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
30 [label="Const: String(test_3)"];
29 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
25 [label="Postponed exit from lambda"];
26 [label="Const: Int(10)"];
27 [label="Function call: R|kotlin/repeat|(...)"];
23 [label="Exit function test_3" style="filled" fillcolor=red];
}
22 -> {24};
24 -> {28};
24 -> {25} [color=red];
25 -> {26};
26 -> {27};
27 -> {23};
28 -> {29 30};
29 -> {28};
29 -> {25} [color=green];
30 -> {29};
subgraph cluster_6 {
color=red
31 [label="Enter function test_4" style="filled" fillcolor=red];
33 [label="Const: Int(1)"];
34 [label="Postponed enter to lambda"];
subgraph cluster_7 {
color=blue
38 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
40 [label="Const: String(test_4)"];
41 [label="Access variable R|<local>/it|"];
42 [label="Const: Int(0)"];
43 [label="Function call: R|<local>/it|.R|kotlin/Int.compareTo|(...)"];
44 [label="Comparison >"];
39 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
37 [label="Call arguments union" style="filled" fillcolor=yellow];
35 [label="Postponed exit from lambda"];
36 [label="Function call: Int(1).R|kotlin/takeUnless|<R|kotlin/Int|>(...)"];
32 [label="Exit function test_4" style="filled" fillcolor=red];
}
31 -> {33};
33 -> {34};
34 -> {38};
34 -> {35} [color=red];
35 -> {36} [color=green];
36 -> {32};
37 -> {36} [color=red];
38 -> {40};
39 -> {35} [color=green];
39 -> {37} [color=red];
40 -> {41};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {39};
subgraph cluster_8 {
color=red
45 [label="Enter function test_5" style="filled" fillcolor=red];
47 [label="Const: Int(1)"];
48 [label="Postponed enter to lambda"];
subgraph cluster_9 {
color=blue
52 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
54 [label="Const: String(test_5)"];
55 [label="Access variable R|<local>/it|"];
56 [label="Const: Int(0)"];
57 [label="Function call: R|<local>/it|.R|kotlin/Int.compareTo|(...)"];
58 [label="Comparison >"];
53 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
51 [label="Call arguments union" style="filled" fillcolor=yellow];
49 [label="Postponed exit from lambda"];
50 [label="Function call: Int(1).R|kotlin/takeUnless|<R|kotlin/Int|>(...)"];
46 [label="Exit function test_5" style="filled" fillcolor=red];
}
45 -> {47};
47 -> {48};
48 -> {52};
48 -> {49} [color=red];
49 -> {50} [color=green];
50 -> {46};
51 -> {50} [color=red];
52 -> {54};
53 -> {49} [color=green];
53 -> {51} [color=red];
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {53};
subgraph cluster_10 {
color=red
59 [label="Enter function myRun" style="filled" fillcolor=red];
61 [label="Function call: R|<local>/block1|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
62 [label="Function call: R|<local>/block2|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
60 [label="Exit function myRun" style="filled" fillcolor=red];
}
59 -> {61};
61 -> {62};
62 -> {60};
subgraph cluster_11 {
color=red
63 [label="Enter function test_6" style="filled" fillcolor=red];
65 [label="Postponed enter to lambda"];
subgraph cluster_12 {
color=blue
70 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
72 [label="Const: String(test_6_1)"];
71 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
66 [label="Postponed exit from lambda"];
67 [label="Postponed enter to lambda"];
subgraph cluster_13 {
color=blue
73 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
75 [label="Const: String(test_6_2)"];
74 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
68 [label="Postponed exit from lambda"];
69 [label="Function call: R|/myRun|(...)"];
64 [label="Exit function test_6" style="filled" fillcolor=red];
}
63 -> {65};
65 -> {70};
65 -> {66} [color=red];
66 -> {67};
67 -> {73};
67 -> {68} [color=red];
68 -> {69};
69 -> {64};
70 -> {71 72};
71 -> {70};
71 -> {66} [color=green];
72 -> {71};
73 -> {74 75};
74 -> {73};
74 -> {68} [color=green];
75 -> {74};
subgraph cluster_14 {
color=red
76 [label="Enter function test_7" style="filled" fillcolor=red];
78 [label="Postponed enter to lambda"];
subgraph cluster_15 {
color=blue
83 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
85 [label="Const: String(test_7_2)"];
84 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
79 [label="Postponed exit from lambda"];
80 [label="Postponed enter to lambda"];
subgraph cluster_16 {
color=blue
86 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
88 [label="Const: String(test_7_1)"];
87 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
81 [label="Postponed exit from lambda"];
82 [label="Function call: R|/myRun|(...)"];
77 [label="Exit function test_7" style="filled" fillcolor=red];
}
76 -> {78};
78 -> {83};
78 -> {79} [color=red];
79 -> {80};
80 -> {86};
80 -> {81} [color=red];
81 -> {82};
82 -> {77};
83 -> {84 85};
84 -> {83};
84 -> {79} [color=green];
85 -> {84};
86 -> {87 88};
87 -> {86};
87 -> {81} [color=green];
88 -> {87};
subgraph cluster_17 {
color=red
89 [label="Enter function myDummyRun" style="filled" fillcolor=red];
91 [label="Function call: R|<local>/block|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
90 [label="Exit function myDummyRun" style="filled" fillcolor=red];
}
89 -> {91};
91 -> {90};
subgraph cluster_18 {
color=red
92 [label="Enter function test_8" style="filled" fillcolor=red];
94 [label="Postponed enter to lambda"];
subgraph cluster_19 {
color=blue
97 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
99 [label="Const: String(test_8)"];
98 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
95 [label="Postponed exit from lambda"];
96 [label="Function call: R|/myDummyRun|(...)"];
93 [label="Exit function test_8" style="filled" fillcolor=red];
}
92 -> {94};
94 -> {95 95} [color=green];
94 -> {97} [color=red];
95 -> {96};
96 -> {93};
97 -> {99};
99 -> {98};
}
@@ -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,339 @@
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];
2 [label="Access variable R|<local>/x|"];
3 [label="Type operator: (R|<local>/x| is R|kotlin/Int|)"];
4 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_1 {
color=blue
5 [label="Enter contract"];
6 [label="Access variable R|<local>/x|"];
7 [label="Type operator: (R|<local>/x| is R|kotlin/Int|)"];
8 [label="Exit contract"];
}
9 [label="Access variable R|<local>/x|"];
10 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
1 [label="Exit function test_1" style="filled" fillcolor=red];
}
0 -> {2};
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {1};
subgraph cluster_2 {
color=red
11 [label="Enter function test_2" style="filled" fillcolor=red];
13 [label="Access variable R|<local>/x|"];
14 [label="Function call: R|kotlin/requireNotNull|<R|kotlin/String|>(...)"];
subgraph cluster_3 {
color=blue
15 [label="Enter contract"];
16 [label="Access variable R|<local>/x|"];
17 [label="Const: Null(null)"];
18 [label="Operator !="];
19 [label="Exit contract"];
}
20 [label="Access variable R|<local>/x|"];
21 [label="Access variable R|kotlin/String.length|"];
12 [label="Exit function test_2" style="filled" fillcolor=red];
}
11 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
16 -> {17};
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {12};
subgraph cluster_4 {
color=red
22 [label="Enter function test_3" style="filled" fillcolor=red];
24 [label="Access variable R|<local>/x|"];
25 [label="Const: Null(null)"];
26 [label="Operator !="];
27 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_5 {
color=blue
28 [label="Enter contract"];
29 [label="Access variable R|<local>/x|"];
30 [label="Const: Null(null)"];
31 [label="Operator !="];
32 [label="Exit contract"];
}
33 [label="Access variable R|<local>/x|"];
34 [label="Access variable R|kotlin/String.length|"];
23 [label="Exit function test_3" style="filled" fillcolor=red];
}
22 -> {24};
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {23};
subgraph cluster_6 {
color=red
35 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
38 [label="Enter &&"];
39 [label="Access variable R|<local>/x|"];
40 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
41 [label="Exit left part of &&"];
42 [label="Enter right part of &&"];
43 [label="Access variable R|<local>/y|"];
44 [label="Const: Null(null)"];
45 [label="Operator !="];
37 [label="Exit &&"];
}
46 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_8 {
color=blue
47 [label="Enter contract"];
subgraph cluster_9 {
color=blue
49 [label="Enter &&"];
50 [label="Access variable R|<local>/x|"];
51 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
52 [label="Exit left part of &&"];
53 [label="Enter right part of &&"];
54 [label="Access variable R|<local>/y|"];
55 [label="Const: Null(null)"];
56 [label="Operator !="];
48 [label="Exit &&"];
}
57 [label="Exit contract"];
}
58 [label="Access variable R|<local>/x|"];
59 [label="Access variable R|kotlin/String.length|"];
60 [label="Access variable R|<local>/y|"];
61 [label="Access variable R|kotlin/String.length|"];
36 [label="Exit function test_4" style="filled" fillcolor=red];
}
35 -> {38};
37 -> {46};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {37 42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {37};
46 -> {47};
47 -> {49};
48 -> {57};
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {48 53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {48};
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {36};
subgraph cluster_10 {
color=red
62 [label="Enter function test_5" style="filled" fillcolor=red];
subgraph cluster_11 {
color=blue
64 [label="Enter when"];
subgraph cluster_12 {
color=blue
66 [label="Enter when branch condition "];
67 [label="Access variable R|<local>/b|"];
68 [label="Exit when branch condition"];
}
subgraph cluster_13 {
color=blue
82 [label="Enter when branch condition else"];
83 [label="Exit when branch condition"];
}
84 [label="Enter when branch result"];
subgraph cluster_14 {
color=blue
85 [label="Enter block"];
86 [label="Access variable R|<local>/x|"];
87 [label="Access variable <Unresolved name: length>#"];
88 [label="Exit block"];
}
89 [label="Exit when branch result"];
69 [label="Enter when branch result"];
subgraph cluster_15 {
color=blue
70 [label="Enter block"];
71 [label="Access variable R|<local>/x|"];
72 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
73 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_16 {
color=blue
74 [label="Enter contract"];
75 [label="Access variable R|<local>/x|"];
76 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
77 [label="Exit contract"];
}
78 [label="Access variable R|<local>/x|"];
79 [label="Access variable R|kotlin/String.length|"];
80 [label="Exit block"];
}
81 [label="Exit when branch result"];
65 [label="Exit when"];
}
90 [label="Access variable R|<local>/x|"];
91 [label="Access variable <Unresolved name: length>#"];
63 [label="Exit function test_5" style="filled" fillcolor=red];
}
62 -> {64};
64 -> {66};
65 -> {90};
66 -> {67};
67 -> {68};
68 -> {69 82};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {76};
76 -> {77};
77 -> {78};
78 -> {79};
79 -> {80};
80 -> {81};
81 -> {65};
82 -> {83};
83 -> {84};
84 -> {85};
85 -> {86};
86 -> {87};
87 -> {88};
88 -> {89};
89 -> {65};
90 -> {91};
91 -> {63};
subgraph cluster_17 {
color=red
92 [label="Enter function test_6" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
94 [label="Enter when"];
subgraph cluster_19 {
color=blue
96 [label="Enter when branch condition "];
97 [label="Access variable R|<local>/b|"];
98 [label="Exit when branch condition"];
}
subgraph cluster_20 {
color=blue
112 [label="Enter when branch condition else"];
113 [label="Exit when branch condition"];
}
114 [label="Enter when branch result"];
subgraph cluster_21 {
color=blue
115 [label="Enter block"];
116 [label="Access variable R|<local>/x|"];
117 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
118 [label="Function call: R|kotlin/require|(...)"];
subgraph cluster_22 {
color=blue
119 [label="Enter contract"];
120 [label="Access variable R|<local>/x|"];
121 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
122 [label="Exit contract"];
}
123 [label="Access variable R|<local>/x|"];
124 [label="Access variable R|kotlin/String.length|"];
125 [label="Exit block"];
}
126 [label="Exit when branch result"];
99 [label="Enter when branch result"];
subgraph cluster_23 {
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_24 {
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"];
95 [label="Exit when"];
}
127 [label="Access variable R|<local>/x|"];
128 [label="Access variable R|kotlin/String.length|"];
93 [label="Exit function test_6" style="filled" fillcolor=red];
}
92 -> {94};
94 -> {96};
95 -> {127};
96 -> {97};
97 -> {98};
98 -> {99 112};
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 -> {95};
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 -> {95};
127 -> {128};
128 -> {93};
}
@@ -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|
}
}
}