"Replace 'if' with elvis operator": Don't suggest on nullable type check #KT-25886 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
1a31ce769c
commit
c6db26ba91
@@ -121,6 +121,7 @@ class FoldInitializerAndIfToElvisIntention : SelfTargetingRangeIntention<KtIfExp
|
|||||||
}
|
}
|
||||||
is KtIsExpression -> {
|
is KtIsExpression -> {
|
||||||
if (!operationExpression.isNegated) return null
|
if (!operationExpression.isNegated) return null
|
||||||
|
if (operationExpression.typeReference?.typeElement is KtNullableType) return null
|
||||||
operationExpression.leftHandSide
|
operationExpression.leftHandSide
|
||||||
}
|
}
|
||||||
else -> return null
|
else -> return null
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
fun test(): String {
|
||||||
|
val foo = foo()
|
||||||
|
<caret>if (foo !is String?) return "0"
|
||||||
|
return "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(): Any? = null
|
||||||
@@ -8436,6 +8436,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
runTest("idea/testData/intentions/foldInitializerAndIfToElvis/NotIs.kt");
|
runTest("idea/testData/intentions/foldInitializerAndIfToElvis/NotIs.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NotIsNullableType.kt")
|
||||||
|
public void testNotIsNullableType() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/foldInitializerAndIfToElvis/NotIsNullableType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("OtherVar1.kt")
|
@TestMetadata("OtherVar1.kt")
|
||||||
public void testOtherVar1() throws Exception {
|
public void testOtherVar1() throws Exception {
|
||||||
runTest("idea/testData/intentions/foldInitializerAndIfToElvis/OtherVar1.kt");
|
runTest("idea/testData/intentions/foldInitializerAndIfToElvis/OtherVar1.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user