Files
kotlin-fork/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/deadCodeInBinaryExpressions.fir.kt
T
Andrey Zinovyev ec4cbfef59 [FIR] UNREACHABLE_CODE diagnostic (wip)
Implementation for PSI only
2021-08-04 14:42:24 +03:00

40 lines
671 B
Kotlin
Vendored

fun testBinary1() {
operator fun Int.times(s: String) {}
todo() <!UNREACHABLE_CODE!>* ""<!>
}
fun testBinary2() {
"1" <!UNREACHABLE_CODE!>+<!> todo()
}
fun testElvis1() {
todo() <!UNREACHABLE_CODE, USELESS_ELVIS!>?: ""<!>
}
fun testElvis2(s: String?) {
s ?: todo()
bar()
}
fun testAnd1(b: Boolean) {
b && todo()
bar()
}
fun testAnd2(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(): Nothing = throw Exception()
fun bar() {}