[FIR] Approximate statements with ILT without expected type

This commit is contained in:
Dmitriy Novozhilov
2020-03-16 10:48:01 +03:00
parent 698f78570d
commit 813003e12e
10 changed files with 43 additions and 36 deletions
@@ -188,7 +188,14 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
val value = if (index == numberOfStatements - 1) data else ResolutionMode.ContextIndependent
TransformData.Data(value)
}
block.transformAllStatementsExceptLast(integerLiteralTypeApproximator, builtinTypes.intType.type)
if (data == ResolutionMode.ContextIndependent) {
block.transformStatements(integerLiteralTypeApproximator, null)
} else {
block.transformAllStatementsExceptLast(
integerLiteralTypeApproximator,
null
)
}
block.transformOtherChildren(transformer, data)
val resultExpression = when (val statement = block.statements.lastOrNull()) {
@@ -28,7 +28,7 @@ digraph binaryOperations_kt {
subgraph cluster_4 {
color=blue
12 [label="Enter block"];
13 [label="Const: IntegerLiteral(1)"];
13 [label="Const: Int(1)"];
14 [label="Exit block"];
}
15 [label="Exit when branch result"];
@@ -80,7 +80,7 @@ digraph binaryOperations_kt {
subgraph cluster_9 {
color=blue
30 [label="Enter block"];
31 [label="Const: IntegerLiteral(1)"];
31 [label="Const: Int(1)"];
32 [label="Exit block"];
}
33 [label="Exit when branch result"];
@@ -140,7 +140,7 @@ digraph binaryOperations_kt {
subgraph cluster_15 {
color=blue
53 [label="Enter block"];
54 [label="Const: IntegerLiteral(1)"];
54 [label="Const: Int(1)"];
55 [label="Exit block"];
}
56 [label="Exit when branch result"];
@@ -205,7 +205,7 @@ digraph binaryOperations_kt {
subgraph cluster_21 {
color=blue
76 [label="Enter block"];
77 [label="Const: IntegerLiteral(1)"];
77 [label="Const: Int(1)"];
78 [label="Exit block"];
}
79 [label="Exit when branch result"];
@@ -2,7 +2,7 @@ FILE: binaryOperations.kt
public final fun test_1(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b1| || R|<local>/b2| -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -10,7 +10,7 @@ FILE: binaryOperations.kt
public final fun test_2(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b1| && R|<local>/b2| -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -18,7 +18,7 @@ FILE: binaryOperations.kt
public final fun test_3(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|, b3: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b1| && R|<local>/b2| || R|<local>/b3| -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -26,7 +26,7 @@ FILE: binaryOperations.kt
public final fun test_4(b1: R|kotlin/Boolean|, b2: R|kotlin/Boolean|, b3: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b1| || R|<local>/b2| && R|<local>/b3| -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -28,7 +28,7 @@ digraph booleanOperatorsWithConsts_kt {
subgraph cluster_4 {
color=blue
12 [label="Enter block"];
13 [label="Const: IntegerLiteral(1)"];
13 [label="Const: Int(1)"];
14 [label="Exit block"];
}
15 [label="Exit when branch result"];
@@ -80,7 +80,7 @@ digraph booleanOperatorsWithConsts_kt {
subgraph cluster_9 {
color=blue
30 [label="Enter block"];
31 [label="Const: IntegerLiteral(1)"];
31 [label="Const: Int(1)"];
32 [label="Exit block"];
}
33 [label="Exit when branch result"];
@@ -133,7 +133,7 @@ digraph booleanOperatorsWithConsts_kt {
subgraph cluster_14 {
color=blue
48 [label="Enter block"];
49 [label="Const: IntegerLiteral(1)"];
49 [label="Const: Int(1)"];
50 [label="Exit block"];
}
51 [label="Exit when branch result"];
@@ -185,7 +185,7 @@ digraph booleanOperatorsWithConsts_kt {
subgraph cluster_19 {
color=blue
66 [label="Enter block"];
67 [label="Const: IntegerLiteral(1)"];
67 [label="Const: Int(1)"];
68 [label="Exit block"];
}
69 [label="Exit when branch result"];
@@ -238,7 +238,7 @@ digraph booleanOperatorsWithConsts_kt {
subgraph cluster_24 {
color=blue
84 [label="Enter block"];
85 [label="Const: IntegerLiteral(1)"];
85 [label="Const: Int(1)"];
86 [label="Exit block"];
}
87 [label="Exit when branch result"];
@@ -290,7 +290,7 @@ digraph booleanOperatorsWithConsts_kt {
subgraph cluster_29 {
color=blue
102 [label="Enter block"];
103 [label="Const: IntegerLiteral(1)"];
103 [label="Const: Int(1)"];
104 [label="Exit block"];
}
105 [label="Exit when branch result"];
@@ -343,7 +343,7 @@ digraph booleanOperatorsWithConsts_kt {
subgraph cluster_34 {
color=blue
120 [label="Enter block"];
121 [label="Const: IntegerLiteral(1)"];
121 [label="Const: Int(1)"];
122 [label="Exit block"];
}
123 [label="Exit when branch result"];
@@ -395,7 +395,7 @@ digraph booleanOperatorsWithConsts_kt {
subgraph cluster_39 {
color=blue
138 [label="Enter block"];
139 [label="Const: IntegerLiteral(1)"];
139 [label="Const: Int(1)"];
140 [label="Exit block"];
}
141 [label="Exit when branch result"];
@@ -2,7 +2,7 @@ FILE: booleanOperatorsWithConsts.kt
public final fun test_1(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| || Boolean(false) -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -10,7 +10,7 @@ FILE: booleanOperatorsWithConsts.kt
public final fun test_2(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
Boolean(false) || R|<local>/b| -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -18,7 +18,7 @@ FILE: booleanOperatorsWithConsts.kt
public final fun test_3(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| || Boolean(true) -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -26,7 +26,7 @@ FILE: booleanOperatorsWithConsts.kt
public final fun test_4(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
Boolean(true) || R|<local>/b| -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -34,7 +34,7 @@ FILE: booleanOperatorsWithConsts.kt
public final fun test_5(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| && Boolean(false) -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -42,7 +42,7 @@ FILE: booleanOperatorsWithConsts.kt
public final fun test_6(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
Boolean(false) && R|<local>/b| -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -50,7 +50,7 @@ FILE: booleanOperatorsWithConsts.kt
public final fun test_7(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
R|<local>/b| && Boolean(true) -> {
IntegerLiteral(1)
Int(1)
}
}
@@ -58,7 +58,7 @@ FILE: booleanOperatorsWithConsts.kt
public final fun test_8(b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
Boolean(true) && R|<local>/b| -> {
IntegerLiteral(1)
Int(1)
}
}
+4 -4
View File
@@ -183,7 +183,7 @@ digraph loops_kt {
subgraph cluster_19 {
color=blue
63 [label="Enter block"];
64 [label="Const: IntegerLiteral(1)"];
64 [label="Const: Int(1)"];
65 [label="Exit block"];
}
66 [label="Exit loop block"];
@@ -301,7 +301,7 @@ digraph loops_kt {
subgraph cluster_32 {
color=blue
100 [label="Enter block" style="filled" fillcolor=gray];
101 [label="Const: IntegerLiteral(1)" style="filled" fillcolor=gray];
101 [label="Const: Int(1)" style="filled" fillcolor=gray];
102 [label="Exit block" style="filled" fillcolor=gray];
}
103 [label="Exit loop block" style="filled" fillcolor=gray];
@@ -338,7 +338,7 @@ digraph loops_kt {
subgraph cluster_36 {
color=blue
110 [label="Enter block"];
111 [label="Const: IntegerLiteral(1)"];
111 [label="Const: Int(1)"];
112 [label="Exit block"];
}
113 [label="Exit loop block"];
@@ -456,7 +456,7 @@ digraph loops_kt {
subgraph cluster_49 {
color=blue
147 [label="Enter block"];
148 [label="Const: IntegerLiteral(1)"];
148 [label="Const: Int(1)"];
149 [label="Exit block"];
}
150 [label="Exit loop block"];
+4 -4
View File
@@ -24,7 +24,7 @@ FILE: loops.kt
}
public final fun testWhileTrue(): R|kotlin/Unit| {
while(Boolean(true)) {
IntegerLiteral(1)
Int(1)
}
Int(1)
@@ -43,14 +43,14 @@ FILE: loops.kt
}
public final fun testWhileFalse(): R|kotlin/Unit| {
while(Boolean(false)) {
IntegerLiteral(1)
Int(1)
}
Int(1)
}
public final fun testDoWhileTrue(): R|kotlin/Unit| {
do {
IntegerLiteral(1)
Int(1)
}
while(Boolean(true))
Int(1)
@@ -69,7 +69,7 @@ FILE: loops.kt
}
public final fun testDoWhileFalse(): R|kotlin/Unit| {
do {
IntegerLiteral(1)
Int(1)
}
while(Boolean(false))
Int(1)
@@ -180,7 +180,7 @@ digraph propertiesAndInitBlocks_kt {
subgraph cluster_18 {
color=blue
57 [label="Enter block"];
58 [label="Const: IntegerLiteral(0)"];
58 [label="Const: Int(0)"];
59 [label="Exit block"];
}
60 [label="Exit finally"];
@@ -52,7 +52,7 @@ FILE: propertiesAndInitBlocks.kt
Int(2)
}
finally {
IntegerLiteral(0)
Int(0)
}
public get(): R|kotlin/Int|
@@ -2,7 +2,7 @@ FILE: exhaustiveness_boolean.kt
public final fun test_1(b: R|kotlin/Boolean|): R|kotlin/Unit| {
lval x: R|kotlin/Unit| = when (R|<local>/b|) {
==($subj$, Boolean(true)) -> {
IntegerLiteral(1)
Int(1)
}
}