"Eliminate argument of 'when'": do not suggest if 'when' is used as expression and it has no 'else' branch (#2898)

#KT-35526 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-08-19 18:24:58 +09:00
committed by GitHub
parent d965ad0a98
commit 8ba5548a0f
5 changed files with 51 additions and 1 deletions
@@ -0,0 +1,11 @@
enum class Type {
HYDRO,
PYRO
}
fun select(t: Type) {
<caret>when (t) {
Type.HYDRO -> 1
Type.PYRO -> 42
}
}
@@ -0,0 +1,11 @@
enum class Type {
HYDRO,
PYRO
}
fun select(t: Type) {
when {
t == Type.HYDRO -> 1
t == Type.PYRO -> 42
}
}
@@ -0,0 +1,12 @@
// IS_APPLICABLE: false
enum class Type {
HYDRO,
PYRO
}
fun select(t: Type): Int {
return <caret>when (t) {
Type.HYDRO -> 1
Type.PYRO -> 42
}
}