Mark expressions for correct recognition by "unreachable code"
This commit is contained in:
@@ -2,32 +2,28 @@
|
||||
fun illegalWhenBlock(a: Any): Any {
|
||||
when(a) {
|
||||
is Int -> return a
|
||||
is String -> return a
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
<START>
|
||||
<START>
|
||||
v(a: Any)
|
||||
w(a)
|
||||
r(a)
|
||||
jmp?(L4) NEXT:[jmp?(L6), r(a)]
|
||||
w(a)
|
||||
mark({ when(a) { is Int -> return a } })
|
||||
mark(when(a) { is Int -> return a })
|
||||
r(a)
|
||||
mark(is Int -> return a)
|
||||
jmp?(L4) NEXT:[<END>, r(a)]
|
||||
L3:
|
||||
r(a)
|
||||
ret(*) L1 NEXT:[<END>]
|
||||
- jmp(L2) NEXT:[<END>] PREV:[]
|
||||
L4:
|
||||
jmp?(L6) NEXT:[<END>, r(a)] PREV:[jmp?(L4)]
|
||||
L5:
|
||||
r(a)
|
||||
ret(*) L1 NEXT:[<END>]
|
||||
- jmp(L2) PREV:[]
|
||||
r(a)
|
||||
ret(*) L1 NEXT:[<END>]
|
||||
- jmp(L2) PREV:[]
|
||||
L1:
|
||||
L2:
|
||||
L6:
|
||||
<END> NEXT:[<SINK>] PREV:[ret(*) L1, jmp?(L6), ret(*) L1]
|
||||
L4:
|
||||
<END> NEXT:[<SINK>] PREV:[jmp?(L4), ret(*) L1]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
fun illegalWhenBlock(a: Any): Any {
|
||||
when(a) {
|
||||
is Int -> return a
|
||||
is String -> return a
|
||||
}
|
||||
}
|
||||
@@ -137,9 +137,9 @@ fun tf() : Int {
|
||||
}
|
||||
|
||||
fun failtest(<!UNUSED_PARAMETER!>a<!> : Int) : Int {
|
||||
if (fail() || <!UNREACHABLE_CODE!>true<!>) {
|
||||
if (fail() || <!UNREACHABLE_CODE!>true<!>) <!UNREACHABLE_CODE!>{
|
||||
|
||||
}
|
||||
}<!>
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
fun foo(<!UNUSED_PARAMETER!>a<!>: Any) {}
|
||||
fun bar(<!UNUSED_PARAMETER!>a<!>: Any, <!UNUSED_PARAMETER!>b<!>: Any) {}
|
||||
|
||||
fun test(arr: Array<Int>) {
|
||||
while (true) {
|
||||
<!UNREACHABLE_CODE!>foo<!>(break)
|
||||
}
|
||||
|
||||
|
||||
while (true) {
|
||||
<!UNREACHABLE_CODE!>bar<!>(arr, break)
|
||||
}
|
||||
|
||||
while (true) {
|
||||
<!UNREACHABLE_CODE!>arr[break]<!>
|
||||
}
|
||||
|
||||
while (true) {
|
||||
<!UNREACHABLE_CODE!>arr[1]<!> = break
|
||||
}
|
||||
|
||||
while (true) {
|
||||
break
|
||||
<!UNREACHABLE_CODE!>foo(1)<!>
|
||||
}
|
||||
|
||||
while (true) {
|
||||
var <!UNUSED_VARIABLE!>x<!> = 1
|
||||
break
|
||||
<!UNREACHABLE_CODE!>x = 2<!>
|
||||
}
|
||||
|
||||
while (true) {
|
||||
var <!UNUSED_VARIABLE!>x<!> = 1
|
||||
<!UNREACHABLE_CODE!>x = break<!>
|
||||
}
|
||||
|
||||
// TODO: bug, should be fixed in CFA
|
||||
while (true) {
|
||||
if (1 > 2 && break && 2 > 3) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: bug, should be fixed in CFA
|
||||
while (true) {
|
||||
if (1 > 2 || break || 2 > 3) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
<!USELESS_ELVIS!>break<!> ?: <!UNREACHABLE_CODE!>null<!>
|
||||
}
|
||||
}
|
||||
@@ -7,5 +7,4 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
// callback is unused due to KT-4233
|
||||
fun test<R>(<!UNUSED_PARAMETER!>callback<!>: (R) -> Unit):Unit = <!UNREACHABLE_CODE!>callback(null!!)<!>
|
||||
fun test<R>(callback: (R) -> Unit):Unit = <!UNREACHABLE_CODE!>callback<!>(null!!)
|
||||
@@ -9,9 +9,9 @@ fun test(a: Int) {
|
||||
bar(a, <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
}
|
||||
fun test1(a: Int) {
|
||||
<!UNREACHABLE_CODE!>foo(a, throw Exception())<!>
|
||||
<!UNREACHABLE_CODE!>foo<!>(a, throw Exception())
|
||||
}
|
||||
|
||||
fun test2(a: Int) {
|
||||
<!UNREACHABLE_CODE!>bar(a, throw Exception())<!>
|
||||
<!UNREACHABLE_CODE!>bar<!>(a, throw Exception())
|
||||
}
|
||||
Reference in New Issue
Block a user