From a51085f923e11b88951ff21bd2f791e715670cea Mon Sep 17 00:00:00 2001 From: Andrey Cherkasov Date: Fri, 21 Jun 2024 01:36:41 +0400 Subject: [PATCH] [kotlin] Port AddEqEqTrueFix to K2 Also provided AddExclExclCallFix for the CONDITION_TYPE_MISMATCH error. ^KTIJ-29577 GitOrigin-RevId: 7f21319738936e4f75f15a2862818d6405378767 --- .../fixes/KotlinK2QuickFixRegistrar.kt | 1 + .../fixes/TypeMismatchFactories.kt | 16 ++++-- .../fixes/HighLevelQuickFixTestGenerated.java | 54 ++++++++++++++++++- .../quickfix/K1QuickFixTestGenerated.java | 36 ++++++++++--- .../addEqEqTrue/{simple2.kt => argument.kt} | 3 +- .../{simple2.kt.after => argument.kt.after} | 3 +- .../quickfix/addEqEqTrue/assignment.kt | 12 +++++ .../quickfix/addEqEqTrue/assignment.kt.after | 12 +++++ .../addEqEqTrue/{simple.kt => condition.kt} | 3 +- .../{simple.kt.after => condition.kt.after} | 3 +- .../quickfix/addEqEqTrue/initializer.kt | 11 ++++ .../quickfix/addEqEqTrue/initializer.kt.after | 11 ++++ .../testData/quickfix/addEqEqTrue/return.kt | 11 ++++ .../quickfix/addEqEqTrue/return.kt.after | 11 ++++ .../addExclExclCall/typeMismatch/condition.kt | 11 ++++ .../typeMismatch/condition.kt.after | 11 ++++ .../codeinsight/GenerateK2QuickFixTests.kt | 2 +- 17 files changed, 193 insertions(+), 18 deletions(-) rename plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/{simple2.kt => argument.kt} (71%) rename plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/{simple2.kt.after => argument.kt.after} (71%) create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/assignment.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/assignment.kt.after rename plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/{simple.kt => condition.kt} (69%) rename plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/{simple.kt.after => condition.kt.after} (69%) create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/initializer.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/initializer.kt.after create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/return.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/return.kt.after create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/addExclExclCall/typeMismatch/condition.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/addExclExclCall/typeMismatch/condition.kt.after diff --git a/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/KotlinK2QuickFixRegistrar.kt b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/KotlinK2QuickFixRegistrar.kt index 5975749ab236..b8d8330c4cd8 100644 --- a/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/KotlinK2QuickFixRegistrar.kt +++ b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/KotlinK2QuickFixRegistrar.kt @@ -250,6 +250,7 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() { registerFactory(TypeMismatchFactories.assignmentTypeMismatch) registerFactory(TypeMismatchFactories.initializerTypeMismatch) registerFactory(TypeMismatchFactories.smartcastImpossibleFactory) + registerFactory(TypeMismatchFactories.conditionTypeMismatchFactory) registerFactory(WrapWithSafeLetCallFixFactories.forUnsafeCall) registerFactory(WrapWithSafeLetCallFixFactories.forUnsafeImplicitInvokeCall) diff --git a/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/TypeMismatchFactories.kt b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/TypeMismatchFactories.kt index e274fbdf38c1..4fdf31ed93c7 100644 --- a/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/TypeMismatchFactories.kt +++ b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/TypeMismatchFactories.kt @@ -1,13 +1,14 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.k2.codeinsight.fixes +import com.intellij.codeInsight.intention.IntentionAction import com.intellij.psi.PsiElement import org.jetbrains.kotlin.analysis.api.KaSession import org.jetbrains.kotlin.analysis.api.fir.diagnostics.KaFirDiagnostic import org.jetbrains.kotlin.analysis.api.types.KaType import org.jetbrains.kotlin.analysis.api.types.KaTypeNullability import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.KotlinQuickFixFactory -import org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix +import org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.utils.addToStdlib.safeAs @@ -39,12 +40,16 @@ object TypeMismatchFactories { getFixesForTypeMismatch(psi, expectedType = diagnostic.desiredType, actualType = actualType) } + val conditionTypeMismatchFactory = KotlinQuickFixFactory.IntentionBased { diagnostic: KaFirDiagnostic.ConditionTypeMismatch -> + getFixesForTypeMismatch(diagnostic.psi, expectedType = builtinTypes.boolean, actualType = diagnostic.actualType) + } + context(KaSession) private fun getFixesForTypeMismatch( psi: PsiElement, expectedType: KaType, actualType: KaType - ): List { + ): List { // TODO: Add more fixes than just AddExclExclCallFix when available. if (!expectedType.canBeNull && actualType.canBeNull) { // We don't want to offer AddExclExclCallFix if we know the expression is definitely null, e.g.: @@ -57,7 +62,12 @@ object TypeMismatchFactories { } val nullableExpectedType = expectedType.withNullability(KaTypeNullability.NULLABLE) if (actualType.isSubtypeOf(nullableExpectedType)) { - return listOfNotNull(psi.asAddExclExclCallFix()) + return buildList { + psi.asAddExclExclCallFix()?.let(::add) + if (expectedType.isBooleanType && psi is KtExpression) { + add(AddEqEqTrueFix(psi).asIntention()) + } + } } } return emptyList() diff --git a/plugins/kotlin/code-insight/fixes-k2/tests/test/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/HighLevelQuickFixTestGenerated.java b/plugins/kotlin/code-insight/fixes-k2/tests/test/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/HighLevelQuickFixTestGenerated.java index 1e6146f0a6e2..5051620e9acc 100644 --- a/plugins/kotlin/code-insight/fixes-k2/tests/test/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/HighLevelQuickFixTestGenerated.java +++ b/plugins/kotlin/code-insight/fixes-k2/tests/test/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/HighLevelQuickFixTestGenerated.java @@ -234,6 +234,11 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu runTest("../../../idea/tests/testData/quickfix/addExclExclCall/typeMismatch/assignmentRValue.kt"); } + @TestMetadata("condition.kt") + public void testCondition() throws Exception { + runTest("../../../idea/tests/testData/quickfix/addExclExclCall/typeMismatch/condition.kt"); + } + @TestMetadata("initializer.kt") public void testInitializer() throws Exception { runTest("../../../idea/tests/testData/quickfix/addExclExclCall/typeMismatch/initializer.kt"); @@ -5407,7 +5412,54 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu + @RunWith(JUnit3RunnerWithInners.class) + @TestMetadata("../../../idea/tests/testData/quickfix/addEqEqTrue") + public static class AddEqEqTrue extends AbstractHighLevelQuickFixTest { + @java.lang.Override + @org.jetbrains.annotations.NotNull + public final KotlinPluginMode getPluginMode() { + return KotlinPluginMode.K2; + } + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("argument.kt") + public void testArgument() throws Exception { + runTest("../../../idea/tests/testData/quickfix/addEqEqTrue/argument.kt"); + } + + @TestMetadata("assignment.kt") + public void testAssignment() throws Exception { + runTest("../../../idea/tests/testData/quickfix/addEqEqTrue/assignment.kt"); + } + + @TestMetadata("condition.kt") + public void testCondition() throws Exception { + runTest("../../../idea/tests/testData/quickfix/addEqEqTrue/condition.kt"); + } + + @TestMetadata("initializer.kt") + public void testInitializer() throws Exception { + runTest("../../../idea/tests/testData/quickfix/addEqEqTrue/initializer.kt"); + } + + @TestMetadata("notBoolean.kt") + public void testNotBoolean() throws Exception { + runTest("../../../idea/tests/testData/quickfix/addEqEqTrue/notBoolean.kt"); + } + + @TestMetadata("notBoolean2.kt") + public void testNotBoolean2() throws Exception { + runTest("../../../idea/tests/testData/quickfix/addEqEqTrue/notBoolean2.kt"); + } + + @TestMetadata("return.kt") + public void testReturn() throws Exception { + runTest("../../../idea/tests/testData/quickfix/addEqEqTrue/return.kt"); + } + } @RunWith(JUnit3RunnerWithInners.class) @TestMetadata("../../../idea/tests/testData/quickfix/addFunModifier") @@ -6061,8 +6113,6 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu - - @RunWith(JUnit3RunnerWithInners.class) @TestMetadata("../../../idea/tests/testData/quickfix/changeObjectToClass") public static class ChangeObjectToClass extends AbstractHighLevelQuickFixTest { diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/K1QuickFixTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/K1QuickFixTestGenerated.java index c1816c7a206d..db8c8823af4c 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/K1QuickFixTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/K1QuickFixTestGenerated.java @@ -795,6 +795,26 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest { KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } + @TestMetadata("argument.kt") + public void testArgument() throws Exception { + runTest("testData/quickfix/addEqEqTrue/argument.kt"); + } + + @TestMetadata("assignment.kt") + public void testAssignment() throws Exception { + runTest("testData/quickfix/addEqEqTrue/assignment.kt"); + } + + @TestMetadata("condition.kt") + public void testCondition() throws Exception { + runTest("testData/quickfix/addEqEqTrue/condition.kt"); + } + + @TestMetadata("initializer.kt") + public void testInitializer() throws Exception { + runTest("testData/quickfix/addEqEqTrue/initializer.kt"); + } + @TestMetadata("notBoolean.kt") public void testNotBoolean() throws Exception { runTest("testData/quickfix/addEqEqTrue/notBoolean.kt"); @@ -805,14 +825,9 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest { runTest("testData/quickfix/addEqEqTrue/notBoolean2.kt"); } - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - runTest("testData/quickfix/addEqEqTrue/simple.kt"); - } - - @TestMetadata("simple2.kt") - public void testSimple2() throws Exception { - runTest("testData/quickfix/addEqEqTrue/simple2.kt"); + @TestMetadata("return.kt") + public void testReturn() throws Exception { + runTest("testData/quickfix/addEqEqTrue/return.kt"); } } @@ -842,6 +857,11 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest { runTest("testData/quickfix/addExclExclCall/typeMismatch/assignmentRValue.kt"); } + @TestMetadata("condition.kt") + public void testCondition() throws Exception { + runTest("testData/quickfix/addExclExclCall/typeMismatch/condition.kt"); + } + @TestMetadata("initializer.kt") public void testInitializer() throws Exception { runTest("testData/quickfix/addExclExclCall/typeMismatch/initializer.kt"); diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple2.kt b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/argument.kt similarity index 71% rename from plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple2.kt rename to plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/argument.kt index 4360d7ecb45a..b0fed594c069 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple2.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/argument.kt @@ -9,4 +9,5 @@ fun test(foo: Foo?) { baz(foo?.bar()) } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple2.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/argument.kt.after similarity index 71% rename from plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple2.kt.after rename to plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/argument.kt.after index be5147b2c2dd..7edc9620bf3e 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple2.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/argument.kt.after @@ -9,4 +9,5 @@ fun test(foo: Foo?) { baz(foo?.bar() == true) } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/assignment.kt b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/assignment.kt new file mode 100644 index 000000000000..b3d783b1a309 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/assignment.kt @@ -0,0 +1,12 @@ +// "Add '== true'" "true" +class Foo { + fun bar() = true +} + +fun test(foo: Foo?) { + val flag: Boolean + flag = foo?.bar() +} + +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/assignment.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/assignment.kt.after new file mode 100644 index 000000000000..90cc8ee7d244 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/assignment.kt.after @@ -0,0 +1,12 @@ +// "Add '== true'" "true" +class Foo { + fun bar() = true +} + +fun test(foo: Foo?) { + val flag: Boolean + flag = foo?.bar() == true +} + +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple.kt b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/condition.kt similarity index 69% rename from plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple.kt rename to plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/condition.kt index c040d520e393..575af11081e1 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/condition.kt @@ -8,4 +8,5 @@ fun test(foo: Foo?) { } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/condition.kt.after similarity index 69% rename from plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple.kt.after rename to plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/condition.kt.after index 3671885a569f..ed54452ae54a 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/simple.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/condition.kt.after @@ -8,4 +8,5 @@ fun test(foo: Foo?) { } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/initializer.kt b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/initializer.kt new file mode 100644 index 000000000000..3d4e13cd8ee2 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/initializer.kt @@ -0,0 +1,11 @@ +// "Add '== true'" "true" +class Foo { + fun bar() = true +} + +fun test(foo: Foo?) { + val flag: Boolean = foo?.bar() +} + +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/initializer.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/initializer.kt.after new file mode 100644 index 000000000000..cc3215698a61 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/initializer.kt.after @@ -0,0 +1,11 @@ +// "Add '== true'" "true" +class Foo { + fun bar() = true +} + +fun test(foo: Foo?) { + val flag: Boolean = foo?.bar() == true +} + +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/return.kt b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/return.kt new file mode 100644 index 000000000000..83d5e1d6edec --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/return.kt @@ -0,0 +1,11 @@ +// "Add '== true'" "true" +class Foo { + fun bar() = true +} + +fun test(foo: Foo?): Boolean { + return foo?.bar() +} + +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/return.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/return.kt.after new file mode 100644 index 000000000000..ba59de18ad57 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/addEqEqTrue/return.kt.after @@ -0,0 +1,11 @@ +// "Add '== true'" "true" +class Foo { + fun bar() = true +} + +fun test(foo: Foo?): Boolean { + return foo?.bar() == true +} + +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddEqEqTrueFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addExclExclCall/typeMismatch/condition.kt b/plugins/kotlin/idea/tests/testData/quickfix/addExclExclCall/typeMismatch/condition.kt new file mode 100644 index 000000000000..152ae7d13069 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/addExclExclCall/typeMismatch/condition.kt @@ -0,0 +1,11 @@ +// "Add non-null asserted (foo?.bar()!!) call" "true" +class Foo { + fun bar() = true +} + +fun test(foo: Foo?) { + if (foo?.bar()) { + } +} +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/addExclExclCall/typeMismatch/condition.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/addExclExclCall/typeMismatch/condition.kt.after new file mode 100644 index 000000000000..2e950a6af765 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/addExclExclCall/typeMismatch/condition.kt.after @@ -0,0 +1,11 @@ +// "Add non-null asserted (foo?.bar()!!) call" "true" +class Foo { + fun bar() = true +} + +fun test(foo: Foo?) { + if (foo?.bar()!!) { + } +} +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix \ No newline at end of file diff --git a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2QuickFixTests.kt b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2QuickFixTests.kt index 08db8fa702eb..eaa4746cdd96 100644 --- a/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2QuickFixTests.kt +++ b/plugins/kotlin/util/test-generator-fir/test/org/jetbrains/kotlin/fir/testGenerator/codeinsight/GenerateK2QuickFixTests.kt @@ -67,7 +67,7 @@ internal fun MutableTWorkspace.generateK2FixTests() { model("$idea/quickfix/addDefaultConstructor", pattern = pattern, isIgnored = true) model("$idea/quickfix/addElseBranchToIf", pattern = pattern) model("$idea/quickfix/addEmptyArgumentList", pattern = pattern, isIgnored = true) - model("$idea/quickfix/addEqEqTrue", pattern = pattern, isIgnored = true) + model("$idea/quickfix/addEqEqTrue", pattern = pattern) model("$idea/quickfix/addFunModifier", pattern = pattern) model("$idea/quickfix/addGenericUpperBound", pattern = pattern, isIgnored = true) model("$idea/quickfix/addInline", pattern = pattern)