Fix tests broken by enhanced RedundantSamConstructor inspection

- The inspection now works in more cases, so the test data had to be
updated accordingly
This commit is contained in:
Roman Golyshev
2020-02-20 17:27:41 +03:00
committed by Roman Golyshev
parent 22a5bc4144
commit 4042214bb2
19 changed files with 110 additions and 30 deletions
@@ -15,6 +15,17 @@
<problem_class severity="WARNING" attribute_key="WEAK_WARNING">Redundant SAM-constructors</problem_class>
<description>Redundant SAM-constructor</description>
</problem>
<problem>
<file>redundantSamConstructor.kt</file>
<line>12</line>
<module>light_idea_test_case</module>
<entry_point TYPE="method" FQNAME="redundantSamConstructor.RedundantSamConstructorKt void test()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
<description>Redundant SAM-constructor</description>
<highlighted_element>Runnable</highlighted_element>
<offset>37</offset>
<length>8</length>
</problem>
<problem>
<file>redundantSamConstructor.kt</file>
<line>22</line>
@@ -39,6 +50,17 @@
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
<description>Redundant SAM-constructor</description>
</problem>
<problem>
<file>redundantSamConstructor.kt</file>
<line>28</line>
<module>light_idea_test_case</module>
<entry_point TYPE="method" FQNAME="redundantSamConstructor.RedundantSamConstructorKt void test()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
<description>Redundant SAM-constructor</description>
<highlighted_element>Runnable</highlighted_element>
<offset>31</offset>
<length>8</length>
</problem>
<problem>
<file>redundantSamConstructor.kt</file>
<line>38</line>
@@ -47,6 +69,17 @@
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
<description>Redundant SAM-constructor</description>
</problem>
<problem>
<file>redundantSamConstructor.kt</file>
<line>44</line>
<module>light_idea_test_case</module>
<entry_point TYPE="method" FQNAME="redundantSamConstructor.RedundantSamConstructorKt void test()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
<description>Redundant SAM-constructor</description>
<highlighted_element>Runnable</highlighted_element>
<offset>27</offset>
<length>8</length>
</problem>
<problem>
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
<line>9</line>
@@ -63,6 +96,17 @@
<problem_class severity="WARNING" attribute_key="WEAK_WARNING">Redundant SAM-constructors</problem_class>
<description>Redundant SAM-constructor</description>
</problem>
<problem>
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
<line>12</line>
<module>light_idea_test_case</module>
<entry_point TYPE="method" FQNAME="redundantSamConstructor.RedundantSamConstructorWithGenericsInReturnTypeKt void testGenericsReturnType()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
<description>Redundant SAM-constructor</description>
<highlighted_element>JFunction0</highlighted_element>
<offset>39</offset>
<length>10</length>
</problem>
<problem>
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
<line>15</line>
@@ -87,6 +131,17 @@
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
<description>Redundant SAM-constructor</description>
</problem>
<problem>
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
<line>21</line>
<module>light_idea_test_case</module>
<entry_point TYPE="method" FQNAME="redundantSamConstructor.RedundantSamConstructorWithGenericsInReturnTypeKt void testGenericsReturnType()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
<description>Redundant SAM-constructor</description>
<highlighted_element>JFunction0</highlighted_element>
<offset>31</offset>
<length>10</length>
</problem>
<problem>
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
<line>24</line>
@@ -173,4 +228,26 @@
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
<description>Redundant SAM-constructor</description>
</problem>
<problem>
<file>redundantSamConstructorWithGenerics.kt</file>
<line>12</line>
<module>light_idea_test_case</module>
<entry_point TYPE="method" FQNAME="redundantSamConstructor.RedundantSamConstructorWithGenericsKt void testGenerics()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
<description>Redundant SAM-constructor</description>
<highlighted_element>JFunction1&lt;String&gt;</highlighted_element>
<offset>39</offset>
<length>18</length>
</problem>
<problem>
<file>redundantSamConstructorWithGenerics.kt</file>
<line>21</line>
<module>light_idea_test_case</module>
<entry_point TYPE="method" FQNAME="redundantSamConstructor.RedundantSamConstructorWithGenericsKt void testGenerics()" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
<description>Redundant SAM-constructor</description>
<highlighted_element>JFunction1&lt;String&gt;</highlighted_element>
<offset>31</offset>
<length>18</length>
</problem>
</problems>
@@ -9,7 +9,7 @@ fun test() {
MyJavaClass.staticFun1({ })
MyJavaClass.staticFun1(runnable)
MyJavaClass.staticFun2({ }, { })
MyJavaClass.staticFun2(runnable, Runnable { })
MyJavaClass.staticFun2(runnable, { })
MyJavaClass.staticFun2({ }, { })
MyJavaClass.staticFun2(
object: Runnable {
@@ -25,7 +25,7 @@ fun test() {
klass.memberFun1({ })
klass.memberFun1(runnable)
klass.memberFun2({ }, { })
klass.memberFun2(runnable, Runnable { })
klass.memberFun2(runnable, { })
klass.memberFun2({ }, { })
klass.memberFun2(
object: Runnable {
@@ -40,4 +40,9 @@ fun test() {
MyJavaClass.staticFunWithOtherParam(1, { })
klass.memberFun1({ })
MyJavaClass.staticFun2({ }, Runnable {
if (p > 0) return@Runnable
print(1)
})
}
@@ -9,7 +9,7 @@ fun testGenerics() {
GenericClass1.staticFun1(JFunction1<String> { })
GenericClass1.staticFun1(runnable)
GenericClass1.staticFun2(JFunction1<String> { }, JFunction1<String> { })
GenericClass1.staticFun2(runnable, JFunction1<String> { })
GenericClass1.staticFun2(runnable, { })
GenericClass1.staticFun2({ s: String -> }, { s: String -> })
GenericClass1.staticFunWithOtherParam(1, JFunction1<String> { })
@@ -18,7 +18,7 @@ fun testGenerics() {
klass.memberFun1(JFunction1<String> { })
klass.memberFun1(runnable)
klass.memberFun2(JFunction1<String> { }, JFunction1<String> { })
klass.memberFun2(runnable, JFunction1<String> { })
klass.memberFun2(runnable, { })
klass.memberFun2({ s: String -> }, { s: String -> })
klass.memberFunWithOtherParam(1, JFunction1<String> { })
@@ -9,7 +9,7 @@ fun testGenericsReturnType() {
GenericClass2.staticFun1({ "" })
GenericClass2.staticFun1(runnable)
GenericClass2.staticFun2({ "" }, { "" })
GenericClass2.staticFun2(runnable, JFunction0 { "" })
GenericClass2.staticFun2(runnable, { "" })
GenericClass2.staticFun2({ -> "" }, { -> "" })
GenericClass2.staticFunWithOtherParam(1, { "" })
@@ -18,7 +18,7 @@ fun testGenericsReturnType() {
klass.memberFun1({ "" })
klass.memberFun1(runnable)
klass.memberFun2({ "" }, { "" })
klass.memberFun2(runnable, JFunction0 { "" })
klass.memberFun2(runnable, { "" })
klass.memberFun2({ -> "" }, { -> "" })
klass.memberFunWithOtherParam(1, { "" })
@@ -14,9 +14,4 @@ fun testNonApplicableAmbiguity(p: Int) {
if (p > 0) return@Runnable
print(1)
})
MyJavaClass.staticFun2(Runnable { }, Runnable {
if (p > 0) return@Runnable
print(1)
})
}
@@ -40,4 +40,9 @@ fun test() {
MyJavaClass.staticFunWithOtherParam(1, java.lang.Runnable { })
klass.memberFun1(java.lang.Runnable { })
MyJavaClass.staticFun2(Runnable { }, Runnable {
if (p > 0) return@Runnable
print(1)
})
}
@@ -3,5 +3,5 @@
fun foo(runnable: Runnable) {}
fun bar() {
foo(Runnable { })
foo { }
}
@@ -5,5 +5,5 @@ import java.io.FileFilter
fun foo(filter: FileFilter) {}
fun bar() {
foo(FileFilter { file -> file.name.startsWith("a") })
foo { file -> file.name.startsWith("a") }
}
@@ -5,5 +5,5 @@ import java.io.FilenameFilter
fun foo(filter: FilenameFilter) {}
fun bar() {
foo(FilenameFilter { file, name -> name == "x" })
foo { file, name -> name == "x" }
}
@@ -5,5 +5,5 @@ import java.io.FileFilter
fun foo(filter: FileFilter) {}
fun bar() {
foo(FileFilter { true })
foo { true }
}
@@ -5,5 +5,5 @@ import java.io.FilenameFilter
fun foo(filter: FilenameFilter) {}
fun bar() {
foo(FilenameFilter { file, name -> true })
foo { file, name -> true }
}
@@ -10,8 +10,7 @@ fun bar() {
val name = file.name
if (name.startsWith("a")) {
return false
}
else {
} else {
if (name.endsWith("b"))
return true
else {
@@ -5,12 +5,11 @@ import java.io.FileFilter
fun foo(filter: FileFilter) {}
fun bar() {
foo(FileFilter { file ->
foo { file ->
val name = file.name
if (name.startsWith("a")) {
false
}
else {
} else {
if (name.endsWith("b"))
true
else {
@@ -18,5 +17,5 @@ fun bar() {
l > 10
}
}
})
}
}
@@ -3,5 +3,5 @@
fun foo(runnable: Runnable) {}
fun bar() {
foo(Runnable { throw UnsupportedOperationException() })
foo { throw UnsupportedOperationException() }
}
@@ -5,5 +5,5 @@ import java.io.FileFilter
fun foo(filter: FileFilter) {}
fun bar() {
foo(FileFilter { file -> file.name.startsWith("a") })
foo { file -> file.name.startsWith("a") }
}
@@ -5,8 +5,8 @@ import java.io.FileFilter
fun foo(filter: FileFilter) {}
fun bar() {
foo(FileFilter { file ->
foo { file ->
val name = file.name
name.startsWith("a")
})
}
}
@@ -9,7 +9,7 @@ class Test {
})
// Applicable
bar(Runnable { println(this@Test) })
bar { println(this@Test) }
// Applicable
bar(object : Runnable {
@@ -8,6 +8,6 @@ internal class Test {
}
fun nya(): Double {
return foo(1, FunctionalI { x: Int -> this.toDouble(x) })
return foo(1, { x: Int -> this.toDouble(x) })
}
}
+2 -2
View File
@@ -9,13 +9,13 @@ class Foo {
private val activity: Activity? = null
fun foo() {
synchronized(this) {
activity!!.runOnUiThread(Runnable { })
activity!!.runOnUiThread { }
}
}
fun bar() {
synchronized(this) {
activity!!.runOnUiThread(Runnable { })
activity!!.runOnUiThread { }
}
}
}