Fix sporadic false-positive "Receiver parameter is never used" for local functions (KT-26481)

This commit is contained in:
Yan Zhulanow
2018-10-19 20:48:42 +03:00
parent f19c0c3fb9
commit 9dd6efeb46
2 changed files with 21 additions and 1 deletions
@@ -76,7 +76,7 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
val receiverTypeDeclaration = receiverType.constructor.declarationDescriptor
if (DescriptorUtils.isCompanionObject(receiverTypeDeclaration)) return
val callable = callableDeclaration.descriptor ?: return
val callable = context[BindingContext.DECLARATION_TO_DESCRIPTOR, callableDeclaration] ?: return
if (callableDeclaration.isMainFunction(callable)) return
@@ -0,0 +1,20 @@
class My(val x: Int)
class Your(val x: Int)
fun Your.foo(): Int {
println(x)
fun My.bar(): Int {
return x
}
return My(0).bar() + x
}
fun bar() {
fun String.foo() = this.length
"".foo()
}
fun baz() {
fun String.foo() = length
"".foo()
}