mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Handle unsafe implicit invoke on array access expression (#1151)
GitOrigin-RevId: 14f92821392f127327f9ce3f2e52b92accc1324b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4ede2be91f
commit
d686e5f561
+2
-1
@@ -21,6 +21,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -92,7 +93,7 @@ class ReplaceInfixOrOperatorCallFix(
|
||||
companion object : KotlinSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||
val expression = diagnostic.psiElement
|
||||
if (expression is KtArrayAccessExpression) {
|
||||
if (expression is KtArrayAccessExpression && diagnostic.factory != Errors.UNSAFE_IMPLICIT_INVOKE_CALL) {
|
||||
if (expression.arrayExpression == null) return null
|
||||
return ReplaceInfixOrOperatorCallFix(expression, expression.shouldHaveNotNullType())
|
||||
}
|
||||
|
||||
+6
@@ -8837,6 +8837,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("invokeOperator.kt")
|
||||
public void testInvokeOperator() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/replaceWithSafeCall/invokeOperator.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("let.kt")
|
||||
public void testLet() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/replaceWithSafeCall/let.kt");
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Replace with safe (?.) call" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
val functions: Map<String, () -> Any> = TODO()
|
||||
|
||||
fun run(name: String) = functions[name]<caret>()
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Replace with safe (?.) call" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
val functions: Map<String, () -> Any> = TODO()
|
||||
|
||||
fun run(name: String) = functions[name]?.invoke()
|
||||
Reference in New Issue
Block a user