Remove explicit type specification: do not suggest for suspend function type
#KT-38310 Fixed
This commit is contained in:
committed by
Yan Zhulanow
parent
098469eb85
commit
329f0227ec
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.idea.refactoring.addTypeArgumentsIfNeeded
|
|||||||
import org.jetbrains.kotlin.idea.refactoring.getQualifiedTypeArgumentList
|
import org.jetbrains.kotlin.idea.refactoring.getQualifiedTypeArgumentList
|
||||||
import org.jetbrains.kotlin.idea.references.mainReference
|
import org.jetbrains.kotlin.idea.references.mainReference
|
||||||
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
|
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
|
||||||
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
@@ -69,6 +70,7 @@ class RemoveExplicitTypeIntention : SelfTargetingRangeIntention<KtCallableDeclar
|
|||||||
if (initializer == null || typeReference == null) return true
|
if (initializer == null || typeReference == null) return true
|
||||||
if (initializer !is KtLambdaExpression && initializer !is KtNamedFunction) return true
|
if (initializer !is KtLambdaExpression && initializer !is KtNamedFunction) return true
|
||||||
val typeElement = typeReference.typeElement ?: return true
|
val typeElement = typeReference.typeElement ?: return true
|
||||||
|
if (typeReference.hasModifier(KtTokens.SUSPEND_KEYWORD)) return false
|
||||||
return when (typeElement) {
|
return when (typeElement) {
|
||||||
is KtFunctionType -> {
|
is KtFunctionType -> {
|
||||||
if (typeElement.receiver != null) return false
|
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 {
|
public void testRemoveUnresolvedType() throws Exception {
|
||||||
runTest("idea/testData/intentions/removeExplicitType/removeUnresolvedType.kt");
|
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")
|
@TestMetadata("idea/testData/intentions/removeExplicitTypeArguments")
|
||||||
|
|||||||
Reference in New Issue
Block a user