Don't show "Convert lambda to reference" for lambdas passed to suspend functions

#KT-16072 Fixed
This commit is contained in:
Dmitry Jemerov
2017-01-31 13:21:47 +01:00
parent 7021b0bf15
commit ffa3cf0027
3 changed files with 18 additions and 0 deletions
@@ -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");