Add "simplify if with constant" inspection #KT-17919 Fixed

This commit is contained in:
Kirill Rakhman
2017-06-28 22:12:14 +03:00
committed by Mikhail Glukhikh
parent 7634673213
commit cb19a86c44
23 changed files with 359 additions and 0 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.ConstantConditionIfInspection
@@ -0,0 +1,8 @@
fun foo(x: Int) {}
fun bar() {
if (<caret>false) {
foo(1)
foo(2)
}
}
@@ -0,0 +1,4 @@
fun foo(x: Int) {}
fun bar() {
}
@@ -0,0 +1,11 @@
// WITH_RUNTIME
fun foo(x: Int) {}
fun bar() {
foo(if (<caret>true) {
foo(1)
foo(2)
1
} else 2)
}
@@ -0,0 +1,11 @@
// WITH_RUNTIME
fun foo(x: Int) {}
fun bar() {
foo(run {
foo(1)
foo(2)
1
})
}
@@ -0,0 +1,6 @@
fun foo(s: String) {}
fun bar() {
if (<caret>true) {
} else 2
}
@@ -0,0 +1,5 @@
fun foo(s: String) {}
fun bar() {
}
@@ -0,0 +1,5 @@
fun foo(x: Int) {}
fun bar() {
foo(if (<caret>true) { 1 } else 2)
}
@@ -0,0 +1,5 @@
fun foo(x: Int) {}
fun bar() {
foo(1)
}
@@ -0,0 +1,5 @@
fun foo(x: Int) {}
fun bar() {
foo(if (<caret>false) 1 else 2)
}
@@ -0,0 +1,5 @@
fun foo(x: Int) {}
fun bar() {
foo(2)
}
@@ -0,0 +1,5 @@
fun foo(x: Int) {}
fun bar() {
foo(if (<caret>true) 1 else 2)
}
@@ -0,0 +1,5 @@
fun foo(x: Int) {}
fun bar() {
foo(1)
}
@@ -0,0 +1,8 @@
fun foo(s: String) {}
fun bar() {
if (<caret>true) {
foo("a")
foo("b")
} else 2
}
@@ -0,0 +1,6 @@
fun foo(s: String) {}
fun bar() {
foo("a")
foo("b")
}