KT-13430 related: add non-null assertion works also for UNSAFE_INFIX_CALL
This commit is contained in:
@@ -102,6 +102,7 @@ class AddExclExclCallFix(val psiElement: PsiElement) : ExclExclCallFix() {
|
||||
val parent = psiElement.parent
|
||||
return when (parent) {
|
||||
is KtUnaryExpression -> parent.baseExpression
|
||||
is KtBinaryExpression -> parent.left
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +202,7 @@ class QuickFixRegistrar : QuickFixContributor {
|
||||
TYPE_MISMATCH.registerFactory(WrapWithSafeLetCallFix.TypeMismatchFactory)
|
||||
|
||||
UNSAFE_CALL.registerFactory(AddExclExclCallFix)
|
||||
UNSAFE_INFIX_CALL.registerFactory(AddExclExclCallFix)
|
||||
UNNECESSARY_NOT_NULL_ASSERTION.registerFactory(RemoveExclExclCallFix)
|
||||
UNSAFE_INFIX_CALL.registerFactory(ReplaceInfixOrOperatorCallFix)
|
||||
UNSAFE_CALL.registerFactory(ReplaceInfixOrOperatorCallFix) // [] only
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
|
||||
class SafeType {
|
||||
operator fun plus(arg: Int) {}
|
||||
}
|
||||
|
||||
fun safeB(p: SafeType?) {
|
||||
val v = p <caret>+ 42
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
|
||||
class SafeType {
|
||||
operator fun plus(arg: Int) {}
|
||||
}
|
||||
|
||||
fun safeB(p: SafeType?) {
|
||||
val v = p!! + 42
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
|
||||
class SafeType {
|
||||
infix fun op(arg: Int) {}
|
||||
}
|
||||
|
||||
fun safeB(p: SafeType?) {
|
||||
val v = p <caret>op 42
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
|
||||
class SafeType {
|
||||
infix fun op(arg: Int) {}
|
||||
}
|
||||
|
||||
fun safeB(p: SafeType?) {
|
||||
val v = p!! op 42
|
||||
}
|
||||
@@ -4770,6 +4770,18 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/expressions"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("fixNullableBinaryWithExclExcl.kt")
|
||||
public void testFixNullableBinaryWithExclExcl() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/expressions/fixNullableBinaryWithExclExcl.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fixNullableInfixWithExclExcl.kt")
|
||||
public void testFixNullableInfixWithExclExcl() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/expressions/fixNullableInfixWithExclExcl.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fixNullableIterableGenericWithExclExcl.kt")
|
||||
public void testFixNullableIterableGenericWithExclExcl() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/expressions/fixNullableIterableGenericWithExclExcl.kt");
|
||||
|
||||
Reference in New Issue
Block a user