Scope function conversion: do not suggest when invoked without receiver
#KT-35525 Fixed
This commit is contained in:
committed by
Ilya Kirillov
parent
8ba5548a0f
commit
f3be3f449a
@@ -80,9 +80,9 @@ private fun getCounterpart(expression: KtCallExpression): String? {
|
|||||||
}
|
}
|
||||||
val bindingContext = callee.analyze(BodyResolveMode.PARTIAL)
|
val bindingContext = callee.analyze(BodyResolveMode.PARTIAL)
|
||||||
val resolvedCall = callee.getResolvedCall(bindingContext) ?: return null
|
val resolvedCall = callee.getResolvedCall(bindingContext) ?: return null
|
||||||
if (resolvedCall.resultingDescriptor.fqNameSafe.asString() == "kotlin.$calleeName" &&
|
val descriptor = resolvedCall.resultingDescriptor
|
||||||
nameResolvesToStdlib(expression, bindingContext, counterpartName)
|
if (descriptor.dispatchReceiverParameter == null && descriptor.extensionReceiverParameter == null) return null
|
||||||
) {
|
if (descriptor.fqNameSafe.asString() == "kotlin.$calleeName" && nameResolvesToStdlib(expression, bindingContext, counterpartName)) {
|
||||||
return counterpartName
|
return counterpartName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// PROBLEM: none
|
||||||
|
fun hello() {
|
||||||
|
<caret>run { }
|
||||||
|
}
|
||||||
+5
@@ -12246,6 +12246,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/scopeFunctions/runToLet/capturedIt.kt");
|
runTest("idea/testData/inspectionsLocal/scopeFunctions/runToLet/capturedIt.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noReceiver.kt")
|
||||||
|
public void testNoReceiver() throws Exception {
|
||||||
|
runTest("idea/testData/inspectionsLocal/scopeFunctions/runToLet/noReceiver.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
@TestMetadata("simple.kt")
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/scopeFunctions/runToLet/simple.kt");
|
runTest("idea/testData/inspectionsLocal/scopeFunctions/runToLet/simple.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user