Redundant Unit inspection: fix false positive for single expression

So #KT-22097 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-01-19 09:39:26 +03:00
committed by Mikhail Glukhikh
parent 30acc224ec
commit 18de0f75ab
16 changed files with 175 additions and 13 deletions
@@ -0,0 +1,5 @@
fun test(b: Boolean): Unit = if (b) {
class A
<caret>Unit
} else {
}
@@ -0,0 +1,4 @@
fun test(b: Boolean): Unit = if (b) {
class A
} else {
}
@@ -0,0 +1,6 @@
// PROBLEM: none
fun test(b: Boolean): Unit = if (b) {
1
<caret>Unit
} else {
}
@@ -0,0 +1,6 @@
// PROBLEM: none
fun test(b: Boolean): Unit = if (b) {
fun a() = 1
<caret>Unit
} else {
}
@@ -0,0 +1,5 @@
fun test(b: Boolean): Unit = try {
fun a() {}
<caret>Unit
} catch (e: Exception) {
}
@@ -0,0 +1,4 @@
fun test(b: Boolean): Unit = try {
fun a() {}
} catch (e: Exception) {
}
@@ -0,0 +1,9 @@
// PROBLEM: none
fun test(b: Boolean): Unit = when (b) {
true -> {
fun a() {}
<caret>Unit
}
else -> {
}
}
@@ -0,0 +1,8 @@
// PROBLEM: none
fun test(b: Boolean): Unit = if (b) {
int()
<caret>Unit
} else {
}
fun int() = 1
@@ -0,0 +1,5 @@
fun test(b: Boolean): Unit = if (b) {
Unit
<caret>Unit
} else {
}
@@ -0,0 +1,4 @@
fun test(b: Boolean): Unit = if (b) {
Unit
} else {
}
@@ -0,0 +1,8 @@
fun test(b: Boolean): Unit = if (b) {
unit()
<caret>Unit
} else {
}
fun unit() {
}
@@ -0,0 +1,7 @@
fun test(b: Boolean): Unit = if (b) {
unit()
} else {
}
fun unit() {
}
@@ -0,0 +1,5 @@
fun test(b: Boolean): Unit = if (b) {
val a = 1
<caret>Unit
} else {
}
@@ -0,0 +1,4 @@
fun test(b: Boolean): Unit = if (b) {
val a = 1
} else {
}