FIR: Report UNSAFE_OPERATOR_CALL for augmented assignments (was
reporting UNSAFE_CALL).
This commit is contained in:
committed by
teamcityserver
parent
ef923d4cfe
commit
32bb64a225
+2
-1
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
+1
-3
@@ -6,6 +6,4 @@ class A {
|
||||
fun foo(b: A) {
|
||||
var a: A? = A()
|
||||
a <caret>+= b
|
||||
}
|
||||
|
||||
/* IGNORE_FIR */
|
||||
}
|
||||
+1
-3
@@ -6,6 +6,4 @@ class A {
|
||||
fun foo(b: A) {
|
||||
var a: A? = A()
|
||||
a?.plusAssign(b)
|
||||
}
|
||||
|
||||
/* IGNORE_FIR */
|
||||
}
|
||||
Reference in New Issue
Block a user