Object to lambda intention is inapplicable when reference to this is used

#KT-10202 In Progress
This commit is contained in:
Natalia Ukhorskaya
2016-01-11 16:31:40 +03:00
parent 41e7c3d70b
commit 2b1d60397d
5 changed files with 98 additions and 1 deletions
@@ -0,0 +1,33 @@
// WITH_RUNTIME
class Test {
fun foo() {
bar(object : Runnable {
override fun run() {
println(this)
}
})
// Applicable
bar(<caret>object : Runnable {
override fun run() {
println(this@Test)
}
})
// Applicable
bar(object : Runnable {
override fun run() {
bar(object : Runnable {
override fun run() {
println(this)
}
})
}
})
}
private fun bar(b: Runnable) {
}
}
@@ -0,0 +1,29 @@
// WITH_RUNTIME
class Test {
fun foo() {
bar(object : Runnable {
override fun run() {
println(this)
}
})
// Applicable
bar(Runnable { println(this@Test) })
// Applicable
bar(object : Runnable {
override fun run() {
bar(object : Runnable {
override fun run() {
println(this)
}
})
}
})
}
private fun bar(b: Runnable) {
}
}
@@ -150,4 +150,20 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
<description>Convert to lambda</description>
</problem>
<problem>
<file>ThisReference.kt</file>
<line>12</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="ThisReference.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
<description>Convert to lambda</description>
</problem>
<problem>
<file>ThisReference.kt</file>
<line>19</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="ThisReference.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
<description>Convert to lambda</description>
</problem>
</problems>