[FE 1.0] Prohibit using non exhaustive if and when in rhs of elvis expression
^KT-44705 ^KT-49349 Fixed
This commit is contained in:
committed by
teamcityserver
parent
06a26a5a74
commit
a2b8493f47
+29
@@ -0,0 +1,29 @@
|
||||
// LANGUAGE: -ProhibitNonExhaustiveIfInRhsOfElvis
|
||||
// DIAGNOSTICS: -USELESS_ELVIS
|
||||
// ISSUE: KT-44705
|
||||
|
||||
fun test_1(x: String?, y: String?) {
|
||||
while (true) {
|
||||
x ?: <!INVALID_IF_AS_EXPRESSION_WARNING!>if<!> (y == null) break
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(x: String?, y: String?) {
|
||||
while (true) {
|
||||
val z = x ?: <!INVALID_IF_AS_EXPRESSION!>if<!> (y == null) break
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: String?, y: String?) {
|
||||
while (true) {
|
||||
x ?: <!NO_ELSE_IN_WHEN_WARNING!>when<!> { true -> break }
|
||||
x ?: <!NO_ELSE_IN_WHEN_WARNING!>when<!> (y) { "hello" -> break }
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4(x: String?, y: String?) {
|
||||
while (true) {
|
||||
val a = x ?: <!NO_ELSE_IN_WHEN!>when<!> { true -> break }
|
||||
val b = x ?: <!NO_ELSE_IN_WHEN!>when<!> (y) { "hello" -> break }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user