From 329f0227ec8d05d81b19000d194d0917bd38b4fa Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Fri, 17 Apr 2020 09:32:04 +0900 Subject: [PATCH] Remove explicit type specification: do not suggest for suspend function type #KT-38310 Fixed --- .../kotlin/idea/intentions/RemoveExplicitTypeIntention.kt | 2 ++ .../intentions/removeExplicitType/suspendFunction.kt | 5 +++++ .../kotlin/idea/intentions/IntentionTestGenerated.java | 5 +++++ 3 files changed, 12 insertions(+) create mode 100644 idea/testData/intentions/removeExplicitType/suspendFunction.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt index 7f241c3cca0..bc2bd34d6a2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeIntention.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.idea.refactoring.addTypeArgumentsIfNeeded import org.jetbrains.kotlin.idea.refactoring.getQualifiedTypeArgumentList import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor +import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset @@ -69,6 +70,7 @@ class RemoveExplicitTypeIntention : SelfTargetingRangeIntention { if (typeElement.receiver != null) return false diff --git a/idea/testData/intentions/removeExplicitType/suspendFunction.kt b/idea/testData/intentions/removeExplicitType/suspendFunction.kt new file mode 100644 index 00000000000..17689f06e83 --- /dev/null +++ b/idea/testData/intentions/removeExplicitType/suspendFunction.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false +fun test() { + val x: suspend (x: Int, y: Int) -> Unit = { x: Int, y: Int -> + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 3aa5c19f764..e0b505ba549 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -13928,6 +13928,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest { public void testRemoveUnresolvedType() throws Exception { runTest("idea/testData/intentions/removeExplicitType/removeUnresolvedType.kt"); } + + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("idea/testData/intentions/removeExplicitType/suspendFunction.kt"); + } } @TestMetadata("idea/testData/intentions/removeExplicitTypeArguments")