mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Make implicit this inspection work for lambda invocation #KT-22970 Fixed
GitOrigin-RevId: e8b376a54719be008c3c37b274786e01e320d95f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b5191c1f3e
commit
46ff484b19
+5
-2
@@ -23,6 +23,7 @@ import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.intentions.getCallableDescriptor
|
||||
import org.jetbrains.kotlin.idea.util.getFactoryForImplicitReceiverWithSubtypeOf
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -52,8 +53,10 @@ class ImplicitThisInspection : AbstractKotlinInspection() {
|
||||
val context = reference.analyze()
|
||||
val scope = reference.getResolutionScope(context) ?: return
|
||||
|
||||
val descriptor = context[BindingContext.REFERENCE_TARGET, reference] as? CallableDescriptor ?: return
|
||||
val receiverDescriptor = descriptor.extensionReceiverParameter ?: descriptor.dispatchReceiverParameter ?: return
|
||||
val descriptor = reference.getCallableDescriptor() ?: return
|
||||
val receiverDescriptor = descriptor.extensionReceiverParameter
|
||||
?: descriptor.dispatchReceiverParameter
|
||||
?: return
|
||||
val receiverType = receiverDescriptor.type
|
||||
|
||||
val expressionFactory = scope.getFactoryForImplicitReceiverWithSubtypeOf(receiverType) ?: return
|
||||
|
||||
+6
@@ -1485,6 +1485,12 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("functionWithReceiver.kt")
|
||||
public void testFunctionWithReceiver() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/implicitThis/functionWithReceiver.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multipleReceivers.kt")
|
||||
public void testMultipleReceivers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/implicitThis/multipleReceivers.kt");
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun CharSequence.foo(bar: CharSequence.() -> Unit){
|
||||
<caret>bar()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun CharSequence.foo(bar: CharSequence.() -> Unit){
|
||||
<caret>this.bar()
|
||||
}
|
||||
Reference in New Issue
Block a user