Files
kotlin/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/deadCodeInBinaryExpressions.kt
Svetlana Isakova 79cec6411d Mark only unreachable parts of element if it has reachable parts
like for 'return todo()' mark only 'return'
2014-06-21 12:26:33 +04:00

39 lines
703 B
Kotlin

fun testBinary1() {
fun Int.times(<!UNUSED_PARAMETER!>s<!>: String) {}
todo() <!UNREACHABLE_CODE!>* ""<!>
}
fun testBinary2() {
"1" <!UNREACHABLE_CODE!>+<!> todo()
}
fun testElvis1() {
<!USELESS_ELVIS!>todo()<!> <!UNREACHABLE_CODE!>?: ""<!>
}
fun testElvis2(s: String?) {
s ?: todo()
bar()
}
fun testAnd1(b: Boolean) {
b && todo()
bar()
}
fun testAnd2(<!UNUSED_PARAMETER!>b<!>: Boolean) {
todo() <!UNREACHABLE_CODE!>&& b<!>
}
fun returnInBinary1(): Boolean {
(return true) <!UNREACHABLE_CODE!>&& (return false)<!>
}
fun returnInBinary2(): Boolean {
(return true) <!UNREACHABLE_CODE!>|| (return false)<!>
}
fun todo() = throw Exception()
fun bar() {}