Don't search twice for the same declaration

This commit is contained in:
Dmitry Jemerov
2017-08-14 17:36:38 +02:00
parent 5b72159967
commit 1fe3f84071
4 changed files with 8 additions and 6 deletions
@@ -276,8 +276,10 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
if (declaration is KtCallableDeclaration) {
val lightMethods = declaration.toLightMethods()
for (method in lightMethods) {
if (!MethodReferencesSearch.search(method).forEach(::checkReference)) return true
if (lightMethods.isNotEmpty()) {
return lightMethods.any { method ->
!MethodReferencesSearch.search(method).forEach(::checkReference)
}
}
}
@@ -2,7 +2,7 @@ package companionObjectUsedInJava
class A {
companion object {
val CONST = 42
@JvmField val CONST = 42
}
}
@@ -15,7 +15,7 @@ class B {
class C {
companion object Named {
val CONST = 42
@JvmField val CONST = 42
}
}
@@ -5,6 +5,6 @@ class Foo {
@JvmStatic fun foo() {
}
val CONST = 111
@JvmField val CONST = 111
}
}
@@ -7,6 +7,6 @@ class usedInJava {
public static void main(String[] args) {
UsedInJavaKt.getUsedByGetter();
UsedInJavaKt.setUsedBySetter(":|");
System.out.println(Obj.CONST);
System.out.println(Obj.getCONST());
}
}