RedundantLetInspection: fix false positive with nullable receiver extension call
#KT-31601 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
a6139f3635
commit
266149b88c
@@ -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()
|
||||
}
|
||||
+10
@@ -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() }
|
||||
}
|
||||
+10
@@ -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 }
|
||||
}
|
||||
+14
@@ -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 }
|
||||
}
|
||||
Reference in New Issue
Block a user