Report UNUSED_EXPRESSION on anonymous functions
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
- Show only changed files in notification "Kotlin not configured"
|
||||
- Configure Kotlin: restore all changed files in undo action
|
||||
- Enable precise incremental compilation by default
|
||||
- Report warning about unused anonymous functions
|
||||
|
||||
### JVM
|
||||
- Remove the compiler option "Xmultifile-facades-open"
|
||||
|
||||
@@ -260,6 +260,7 @@ fun Instruction.calcSideEffectFree(): Boolean {
|
||||
}
|
||||
|
||||
else -> when (element) {
|
||||
is KtNamedFunction -> element.name == null
|
||||
is KtConstantExpression, is KtLambdaExpression, is KtStringTemplateExpression -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
+4
-4
@@ -18,9 +18,9 @@ class Outer {
|
||||
}
|
||||
|
||||
fun outerFun() {
|
||||
fun () {}
|
||||
fun B.() {}
|
||||
<!UNUSED_EXPRESSION!>fun () {}<!>
|
||||
<!UNUSED_EXPRESSION!>fun B.() {}<!>
|
||||
|
||||
@a fun () {}
|
||||
fun @a A.() {}
|
||||
<!UNUSED_EXPRESSION!>@a fun () {}<!>
|
||||
<!UNUSED_EXPRESSION!>fun @a A.() {}<!>
|
||||
}
|
||||
Vendored
+8
-8
@@ -1,21 +1,21 @@
|
||||
fun unusedExpressions() {
|
||||
if (1 == 1)
|
||||
fun(): Int {return 1}
|
||||
<!UNUSED_EXPRESSION!>fun(): Int {return 1}<!>
|
||||
else
|
||||
fun() = 1
|
||||
<!UNUSED_EXPRESSION!>fun() = 1<!>
|
||||
|
||||
if (1 == 1) {
|
||||
fun(): Int {
|
||||
<!UNUSED_EXPRESSION!>fun(): Int {
|
||||
return 1
|
||||
}
|
||||
}<!>
|
||||
}
|
||||
else
|
||||
fun() = 1
|
||||
<!UNUSED_EXPRESSION!>fun() = 1<!>
|
||||
|
||||
when (1) {
|
||||
0 -> fun(): Int {return 1}
|
||||
else -> fun() = 1
|
||||
0 -> <!UNUSED_EXPRESSION!>fun(): Int {return 1}<!>
|
||||
else -> <!UNUSED_EXPRESSION!>fun() = 1<!>
|
||||
}
|
||||
|
||||
fun() = 1
|
||||
<!UNUSED_EXPRESSION!>fun() = 1<!>
|
||||
}
|
||||
|
||||
@@ -58,11 +58,11 @@ class Outer {
|
||||
}
|
||||
|
||||
fun outerFun() {
|
||||
fun () {
|
||||
<!UNUSED_EXPRESSION!>fun () {
|
||||
|
||||
}
|
||||
fun () {
|
||||
}<!>
|
||||
<!UNUSED_EXPRESSION!>fun () {
|
||||
|
||||
}
|
||||
}<!>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// KT-306 Ambiguity when different this's have same-looking functions
|
||||
|
||||
fun test() {
|
||||
(fun Foo.() {
|
||||
(<!UNUSED_EXPRESSION!>fun Foo.() {
|
||||
bar()
|
||||
(fun Barr.() {
|
||||
(<!UNUSED_EXPRESSION!>fun Barr.() {
|
||||
this.bar()
|
||||
bar()
|
||||
})
|
||||
})
|
||||
(fun Barr.() {
|
||||
}<!>)
|
||||
}<!>)
|
||||
(<!UNUSED_EXPRESSION!>fun Barr.() {
|
||||
this.bar()
|
||||
bar()
|
||||
})
|
||||
}<!>)
|
||||
}
|
||||
|
||||
class Foo {
|
||||
|
||||
Reference in New Issue
Block a user