Don't show "Convert lambda to reference" for lambdas passed to suspend functions
#KT-16072 Fixed
This commit is contained in:
@@ -87,6 +87,8 @@ class ConvertLambdaToReferenceIntention : SelfTargetingOffsetIndependentIntentio
|
||||
if (calleeDescriptor.typeParameters.isNotEmpty()) return false
|
||||
// No references to Java synthetic properties
|
||||
if (calleeDescriptor is SyntheticJavaPropertyDescriptor) return false
|
||||
// No suspend functions
|
||||
if ((calleeDescriptor as? FunctionDescriptor)?.isSuspend ?: false) return false
|
||||
val descriptorHasReceiver = with(calleeDescriptor) {
|
||||
// No references to both member / extension
|
||||
if (dispatchReceiverParameter != null && extensionReceiverParameter != null) return false
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
|
||||
suspend fun String.bar() {
|
||||
|
||||
}
|
||||
|
||||
suspend fun x() {
|
||||
listOf("Jack", "Tom").forEach <caret>{ it.bar() }
|
||||
}
|
||||
@@ -4463,6 +4463,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFun.kt")
|
||||
public void testSuspendFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertLambdaToReference/suspendFun.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticProperty.kt")
|
||||
public void testSyntheticProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertLambdaToReference/syntheticProperty.kt");
|
||||
|
||||
Reference in New Issue
Block a user