Take control flow into account for checking fall-through switch branches

#KT-16133 Fixed
This commit is contained in:
Dmitry Neverov
2017-05-09 16:01:51 +02:00
committed by Simon Ogorodnik
parent 31478f8efa
commit 3002639fd7
11 changed files with 180 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
//method
public String foo(int i, int j) {
switch (i) {
case 0:
if (j > 0) {
return "1"
} else{
return "2"
}
case 1:
return "3";
default:
return "4";
}
}
+11
View File
@@ -0,0 +1,11 @@
fun foo(i: Int, j: Int): String {
when (i) {
0 -> if (j > 0) {
return "1"
} else {
return "2"
}
1 -> return "3"
else -> return "4"
}
}
+13
View File
@@ -0,0 +1,13 @@
//method
public String foo(int i, int j) {
switch (i) {
case 0:
if (j > 0) {
return "1"
}
case 1:
return "2";
default:
return "3";
}
}
+12
View File
@@ -0,0 +1,12 @@
fun foo(i: Int, j: Int): String {
when (i) {
0 -> {
if (j > 0) {
return "1"
}
return "2"
}
1 -> return "2"
else -> return "3"
}
}
+16
View File
@@ -0,0 +1,16 @@
//method
public String foo(int i, int j) {
switch (i) {
case 0:
switch (j) {
case 1:
return "0, 1";
default:
return "0, x";
}
case 1:
return "1, x";
default:
return "x, x";
}
}
+10
View File
@@ -0,0 +1,10 @@
fun foo(i: Int, j: Int): String {
when (i) {
0 -> when (j) {
1 -> return "0, 1"
else -> return "0, x"
}
1 -> return "1, x"
else -> return "x, x"
}
}
@@ -0,0 +1,15 @@
//method
public String foo(int i, int j) {
switch (i) {
case 0:
switch (j) {
case 1:
return "0, 1";
case 2:
return "0, 2";
}
case 1:
return "1, x";
default:
return "x, x";
}
@@ -0,0 +1,13 @@
fun foo(i: Int, j: Int): String {
when (i) {
0 -> {
when (j) {
1 -> return "0, 1"
2 -> return "0, 2"
}
return "1, x"
}
1 -> return "1, x"
else -> return "x, x"
}
}