Introduce inspection to detect use of Unit as a standalone expression
So #KT-20631 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
5f4233e4bf
commit
ef71f7707d
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.RedundantUnitExpressionInspection
|
||||
@@ -0,0 +1,4 @@
|
||||
// PROBLEM: none
|
||||
fun test() {
|
||||
val u = <caret>Unit
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
fun test() = <caret>Unit
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
fun test(s: String?) {
|
||||
val x: Any = if (s == null)
|
||||
""
|
||||
else
|
||||
Unit<caret>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun test() {
|
||||
return <caret>Unit
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun test() {
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun test() {
|
||||
val f: () -> Unit = {
|
||||
<caret>Unit
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun test() {
|
||||
val f: () -> Unit = {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun test() {
|
||||
val f: () -> Unit = {
|
||||
<caret>Unit
|
||||
Unit
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun test() {
|
||||
val f: () -> Unit = {
|
||||
Unit
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test(s: String?) {
|
||||
val x: Any = if (s == null) {
|
||||
""
|
||||
}
|
||||
else {
|
||||
<caret>Unit
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun test(s: String?) {
|
||||
val x: Any = if (s == null) {
|
||||
""
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test() {
|
||||
val x: List<Unit> = listOf(1, 2, 3).map {
|
||||
return@map <caret>Unit
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test() {
|
||||
val x: List<Unit> = listOf(1, 2, 3).map {
|
||||
return@map
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user