Remove explicit type specification: do not suggest for suspend function type

#KT-38310 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-04-17 09:32:04 +09:00
committed by Yan Zhulanow
parent 098469eb85
commit 329f0227ec
3 changed files with 12 additions and 0 deletions
@@ -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<KtCallableDeclar
if (initializer == null || typeReference == null) return true
if (initializer !is KtLambdaExpression && initializer !is KtNamedFunction) return true
val typeElement = typeReference.typeElement ?: return true
if (typeReference.hasModifier(KtTokens.SUSPEND_KEYWORD)) return false
return when (typeElement) {
is KtFunctionType -> {
if (typeElement.receiver != null) return false
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
fun test() {
val x: suspend (x: Int, y: Int) -> Unit<caret> = { x: Int, y: Int ->
}
}
@@ -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")