Fix sporadic false-positive "Receiver parameter is never used" for local functions (KT-26481)
This commit is contained in:
@@ -76,7 +76,7 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
|
|||||||
val receiverTypeDeclaration = receiverType.constructor.declarationDescriptor
|
val receiverTypeDeclaration = receiverType.constructor.declarationDescriptor
|
||||||
if (DescriptorUtils.isCompanionObject(receiverTypeDeclaration)) return
|
if (DescriptorUtils.isCompanionObject(receiverTypeDeclaration)) return
|
||||||
|
|
||||||
val callable = callableDeclaration.descriptor ?: return
|
val callable = context[BindingContext.DECLARATION_TO_DESCRIPTOR, callableDeclaration] ?: return
|
||||||
|
|
||||||
if (callableDeclaration.isMainFunction(callable)) 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()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user