FIR: Report UNSAFE_OPERATOR_CALL for augmented assignments (was

reporting UNSAFE_CALL).
This commit is contained in:
Mark Punzalan
2021-05-25 17:56:59 +00:00
committed by teamcityserver
parent ef923d4cfe
commit 32bb64a225
12 changed files with 93 additions and 12 deletions
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.idea.quickfix.ReplaceInfixOrOperatorCallFix
import org.jetbrains.kotlin.idea.quickfix.ReplaceWithSafeCallFix
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
import org.jetbrains.kotlin.psi.psiUtil.unwrapParenthesesLabelsAndAnnotations
import org.jetbrains.kotlin.types.expressions.OperatorConventions
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -62,7 +63,7 @@ object ReplaceCallFixFactories {
return@diagnosticFixFactory emptyList()
}
val target = psi.parent as? KtBinaryExpression ?: return@diagnosticFixFactory emptyList()
val target = psi.getNonStrictParentOfType<KtBinaryExpression>() ?: return@diagnosticFixFactory emptyList()
listOf(ReplaceInfixOrOperatorCallFix(target, shouldHaveNotNullType(target), diagnostic.operator))
}
@@ -16741,6 +16741,11 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.kt");
}
@TestMetadata("augmentedAssignment.kt")
public void testAugmentedAssignment() throws Exception {
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/augmentedAssignment.kt");
}
@TestMetadata("dataFlowInfoAfterExclExcl.kt")
public void testDataFlowInfoAfterExclExcl() throws Exception {
runTest("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/dataFlowInfoAfterExclExcl.kt");
@@ -6,6 +6,4 @@ class A {
fun foo(b: A) {
var a: A? = A()
a <caret>+= b
}
/* IGNORE_FIR */
}
@@ -6,6 +6,4 @@ class A {
fun foo(b: A) {
var a: A? = A()
a?.plusAssign(b)
}
/* IGNORE_FIR */
}