RedundantLetInspection: fix false positive with nullable receiver extension call

#KT-31601 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-02-03 10:46:10 +09:00
committed by Dmitry Gridin
parent a6139f3635
commit 266149b88c
7 changed files with 79 additions and 4 deletions
@@ -0,0 +1,6 @@
// WITH_RUNTIME
fun String.foo() {}
fun test(s: String?) {
s?.let<caret> { it.foo() }
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
fun String.foo() {}
fun test(s: String?) {
s?.foo()
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
// PROBLEM: none
class Optional<out T>(val value: T)
fun Any?.foo() = println("foo: $this")
fun main() {
val b: Optional<Any?>? = Optional(null)
b?.let<caret> { it.value.foo() }
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
// PROBLEM: none
class Optional<out T>(val value: T)
val Any?.foo get() = println("foo: $this")
fun main() {
val b: Optional<Any?>? = Optional(null)
b?.let<caret> { it.value.foo }
}
@@ -0,0 +1,14 @@
// WITH_RUNTIME
// PROBLEM: none
class A(val b: B?)
class B
class C(val d: D)
class D
fun B?.getC(): C {
return C(D())
}
fun test(a: A?) {
a?.let<caret> { it.b.getC().d }
}