From 07e4774d29d9c0bca0ba5e584f2e67c2df74a107 Mon Sep 17 00:00:00 2001 From: Andrey Cherkasov Date: Fri, 14 Jun 2024 02:36:53 +0400 Subject: [PATCH] [kotlin] Port ConvertStringToCharLiteralFix to K2 ^KTIJ-29624 GitOrigin-RevId: c6a20b852b88c9e21106d45f8832423373ec3557 --- .../ConvertStringToCharLiteralFixFactory.kt | 75 +++++++++++++++++++ .../fixes/KotlinK2QuickFixRegistrar.kt | 10 +++ .../fixes/HighLevelQuickFixTestGenerated.java | 75 ++++++++++++++++++- .../quickfix/K1QuickFixTestGenerated.java | 26 ++++++- .../charLiteralConversion/charEqString.kt | 2 +- .../charEqString.kt.after | 2 +- .../charLiteralConversion/charEqString2.kt | 2 +- .../charEqString2.kt.after | 2 +- .../charLiteralConversion/charEqString3.kt | 2 +- .../charEqString3.kt.after | 2 +- .../charEqStringDoubleQuote.kt | 2 +- .../charEqStringDoubleQuote.kt.after | 2 +- .../charEqStringSingleQuote.kt | 2 +- .../charEqStringSingleQuote.kt.after | 2 +- .../cannotConvertStringToCharLiteral.kt | 5 ++ .../convertAssignedStringToCharLiteral.kt | 8 ++ ...onvertAssignedStringToCharLiteral.kt.after | 8 ++ ...kt => convertReturnStringToCharLiteral.kt} | 2 +- ...convertReturnStringToCharLiteral.kt.after} | 2 +- .../convertStringInitializerToCharLiteral.kt | 6 ++ ...ertStringInitializerToCharLiteral.kt.after | 6 ++ .../typeMismatch/incompatibleTypes/byte.kt | 3 +- .../incompatibleTypes/byte.kt.after | 3 +- .../incompatibleTypes/changeReturnType.kt | 3 +- .../changeReturnType.kt.after | 3 +- .../typeMismatch/incompatibleTypes/char.kt | 3 +- .../incompatibleTypes/char.kt.after | 3 +- .../typeMismatch/incompatibleTypes/int.kt | 3 +- .../incompatibleTypes/int.kt.after | 3 +- .../incompatibleTypes/toString.kt | 3 +- .../incompatibleTypes/toString.kt.after | 3 +- .../wrapWithCollectionLiteral.kt | 3 +- .../wrapWithCollectionLiteral.kt.after | 3 +- .../parameterTypeMismatch/char.kt | 8 ++ .../parameterTypeMismatch/char.kt.after | 8 ++ .../codeinsight/GenerateK2QuickFixTests.kt | 1 + 36 files changed, 266 insertions(+), 30 deletions(-) create mode 100644 plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/ConvertStringToCharLiteralFixFactory.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/cannotConvertStringToCharLiteral.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt.after rename plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/{convertStringToCharLiteral.kt => convertReturnStringToCharLiteral.kt} (56%) rename plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/{convertStringToCharLiteral.kt.after => convertReturnStringToCharLiteral.kt.after} (56%) create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt.after create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt create mode 100644 plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt.after diff --git a/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/ConvertStringToCharLiteralFixFactory.kt b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/ConvertStringToCharLiteralFixFactory.kt new file mode 100644 index 000000000000..5bfd10d8945f --- /dev/null +++ b/plugins/kotlin/code-insight/fixes-k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/fixes/ConvertStringToCharLiteralFixFactory.kt @@ -0,0 +1,75 @@ +// 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.modcommand.ActionContext +import com.intellij.modcommand.ModPsiUpdater +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.analysis.api.KaSession +import org.jetbrains.kotlin.analysis.api.components.KaConstantEvaluationMode +import org.jetbrains.kotlin.analysis.api.fir.diagnostics.KaFirDiagnostic +import org.jetbrains.kotlin.analysis.api.types.KaType +import org.jetbrains.kotlin.idea.base.resources.KotlinBundle +import org.jetbrains.kotlin.idea.codeinsight.api.applicable.intentions.KotlinPsiUpdateModCommandAction +import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.KotlinQuickFixFactory +import org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralUtils +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtProperty +import org.jetbrains.kotlin.psi.KtStringTemplateExpression + +internal object ConvertStringToCharLiteralFixFactory { + + val argumentTypeMismatchFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.ArgumentTypeMismatch -> + getFixes(diagnostic.psi, diagnostic.expectedType) + } + + val assignmentTypeMismatchFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.AssignmentTypeMismatch -> + getFixes(diagnostic.psi, diagnostic.expectedType) + } + + val equalityNotApplicableFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.EqualityNotApplicable -> + val element = diagnostic.psi + getFixes(element.left, diagnostic.rightType).takeUnless { it.isEmpty() } ?: getFixes(element.right, diagnostic.leftType) + } + + val incompatibleTypesFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.IncompatibleTypes -> + getFixes(diagnostic.psi, diagnostic.typeA) + } + + val initializerTypeMismatchFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.InitializerTypeMismatch -> + getFixes((diagnostic.psi as? KtProperty)?.initializer, diagnostic.expectedType) + } + + val returnTypeMismatchFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.ReturnTypeMismatch -> + getFixes(diagnostic.psi, diagnostic.expectedType) + } + + context(KaSession) + private fun getFixes(element: PsiElement?, expectedType: KaType): List { + if (element !is KtStringTemplateExpression) return emptyList() + if (!expectedType.isChar) return emptyList() + + val charLiteral = ConvertStringToCharLiteralUtils.prepareCharLiteral(element) ?: return emptyList() + if (charLiteral.evaluate(KaConstantEvaluationMode.CONSTANT_EXPRESSION_EVALUATION) == null) return emptyList() + + return listOf( + ConvertStringToCharLiteralFix(element, charLiteral) + ) + } + + private class ConvertStringToCharLiteralFix( + element: KtStringTemplateExpression, + private val charLiteral: KtExpression, // No need for `SmartPsiElementPointer` since the expression is created by `KtPsiFactory` + ) : KotlinPsiUpdateModCommandAction.ElementBased(element, Unit) { + + override fun getFamilyName() = KotlinBundle.message("convert.string.to.character.literal") + + override fun invoke( + actionContext: ActionContext, + element: KtStringTemplateExpression, + elementContext: Unit, + updater: ModPsiUpdater, + ) { + element.replace(charLiteral) + } + } +} 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 38365ce9a85f..2d9902f2ceef 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 @@ -145,6 +145,15 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() { registerFactory(ChangeToLabeledReturnFixFactory.returnTypeMismatch) } + private val convertStringToCharLiteral = KtQuickFixesListBuilder.registerPsiQuickFix { + registerFactory(ConvertStringToCharLiteralFixFactory.argumentTypeMismatchFactory) + registerFactory(ConvertStringToCharLiteralFixFactory.assignmentTypeMismatchFactory) + registerFactory(ConvertStringToCharLiteralFixFactory.equalityNotApplicableFactory) + registerFactory(ConvertStringToCharLiteralFixFactory.incompatibleTypesFactory) + registerFactory(ConvertStringToCharLiteralFixFactory.initializerTypeMismatchFactory) + registerFactory(ConvertStringToCharLiteralFixFactory.returnTypeMismatchFactory) + } + private val insertDelegationCall = KtQuickFixesListBuilder.registerPsiQuickFix { registerFactory(InsertDelegationCallFixFactory.primaryConstructorDelegationCallExpected) registerFactory(InsertDelegationCallFixFactory.explicitDelegationCallRequiredSuper) @@ -407,6 +416,7 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() { addFinal, addInline, changeToLabeledReturn, + convertStringToCharLiteral, insertDelegationCall, propertyInitialization, overrides, 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 b28ba38af946..8dc1677a1dcd 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 @@ -3797,6 +3797,55 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu } } + @RunWith(JUnit3RunnerWithInners.class) + @TestMetadata("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes") + public static class IncompatibleTypes 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("byte.kt") + public void testByte() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt"); + } + + @TestMetadata("changeReturnType.kt") + public void testChangeReturnType() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt"); + } + + @TestMetadata("char.kt") + public void testChar() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt"); + } + + @TestMetadata("char2.kt") + public void testChar2() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char2.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt"); + } + + @TestMetadata("toString.kt") + public void testToString() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt"); + } + + @TestMetadata("wrapWithCollectionLiteral.kt") + public void testWrapWithCollectionLiteral() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt"); + } + } + @RunWith(JUnit3RunnerWithInners.class) @TestMetadata("../../../idea/tests/testData/quickfix/typeMismatch/numberConversion") public abstract static class NumberConversion extends AbstractHighLevelQuickFixTest { @@ -4079,6 +4128,11 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu runTest("../../../idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changePrimaryConstructorParameterTypeOnPropertyDelegate.kt"); } + @TestMetadata("char.kt") + public void testChar() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt"); + } + @TestMetadata("convertKClassToJavaClass.kt") public void testConvertKClassToJavaClass() throws Exception { runTest("../../../idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/convertKClassToJavaClass.kt"); @@ -4484,6 +4538,11 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu runTest("../../../idea/tests/testData/quickfix/typeMismatch/anyInReturn.kt"); } + @TestMetadata("cannotConvertStringToCharLiteral.kt") + public void testCannotConvertStringToCharLiteral() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/cannotConvertStringToCharLiteral.kt"); + } + @TestMetadata("changeFunctionLiteralParameterTypeToFunctionType.kt") public void testChangeFunctionLiteralParameterTypeToFunctionType() throws Exception { runTest("../../../idea/tests/testData/quickfix/typeMismatch/changeFunctionLiteralParameterTypeToFunctionType.kt"); @@ -4564,9 +4623,19 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu runTest("../../../idea/tests/testData/quickfix/typeMismatch/constantTypeMismatch.kt"); } - @TestMetadata("convertStringToCharLiteral.kt") - public void testConvertStringToCharLiteral() throws Exception { - runTest("../../../idea/tests/testData/quickfix/typeMismatch/convertStringToCharLiteral.kt"); + @TestMetadata("convertAssignedStringToCharLiteral.kt") + public void testConvertAssignedStringToCharLiteral() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt"); + } + + @TestMetadata("convertReturnStringToCharLiteral.kt") + public void testConvertReturnStringToCharLiteral() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt"); + } + + @TestMetadata("convertStringInitializerToCharLiteral.kt") + public void testConvertStringInitializerToCharLiteral() throws Exception { + runTest("../../../idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt"); } @TestMetadata("dontChangeOverriddenPropertyTypeToErrorType.kt") 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 09387c4a834e..c1816c7a206d 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 @@ -18136,6 +18136,11 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest { runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/changePrimaryConstructorParameterTypeOnPropertyDelegate.kt"); } + @TestMetadata("char.kt") + public void testChar() throws Exception { + runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt"); + } + @TestMetadata("convertKClassToJavaClass.kt") public void testConvertKClassToJavaClass() throws Exception { runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/convertKClassToJavaClass.kt"); @@ -18501,6 +18506,11 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest { runTest("testData/quickfix/typeMismatch/anyInReturn.kt"); } + @TestMetadata("cannotConvertStringToCharLiteral.kt") + public void testCannotConvertStringToCharLiteral() throws Exception { + runTest("testData/quickfix/typeMismatch/cannotConvertStringToCharLiteral.kt"); + } + @TestMetadata("changeFunctionLiteralParameterTypeToFunctionType.kt") public void testChangeFunctionLiteralParameterTypeToFunctionType() throws Exception { runTest("testData/quickfix/typeMismatch/changeFunctionLiteralParameterTypeToFunctionType.kt"); @@ -18581,9 +18591,19 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest { runTest("testData/quickfix/typeMismatch/constantTypeMismatch.kt"); } - @TestMetadata("convertStringToCharLiteral.kt") - public void testConvertStringToCharLiteral() throws Exception { - runTest("testData/quickfix/typeMismatch/convertStringToCharLiteral.kt"); + @TestMetadata("convertAssignedStringToCharLiteral.kt") + public void testConvertAssignedStringToCharLiteral() throws Exception { + runTest("testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt"); + } + + @TestMetadata("convertReturnStringToCharLiteral.kt") + public void testConvertReturnStringToCharLiteral() throws Exception { + runTest("testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt"); + } + + @TestMetadata("convertStringInitializerToCharLiteral.kt") + public void testConvertStringInitializerToCharLiteral() throws Exception { + runTest("testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt"); } @TestMetadata("dontChangeOverriddenPropertyTypeToErrorType.kt") diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString.kt b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString.kt index 4ab78dff37b1..8443e077b162 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString.kt @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return c == "a" } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString.kt.after index 33e3742865c0..ebc7a92d452c 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString.kt.after @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return c == 'a' } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString2.kt b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString2.kt index 2dc8beeb1193..f900b71aec7f 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString2.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString2.kt @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return "\t" == c } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString2.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString2.kt.after index 4fc741927026..287ecd10460e 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString2.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString2.kt.after @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return '\t' == c } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString3.kt b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString3.kt index 8c9890a22eec..a6f29d206592 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString3.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString3.kt @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return c == """a""" } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString3.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString3.kt.after index 33e3742865c0..ebc7a92d452c 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString3.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqString3.kt.after @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return c == 'a' } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringDoubleQuote.kt b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringDoubleQuote.kt index 52c57c546abf..26808c81709f 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringDoubleQuote.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringDoubleQuote.kt @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return c == "\"" } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringDoubleQuote.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringDoubleQuote.kt.after index 2f0cf1cf4dd2..e842f50fb416 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringDoubleQuote.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringDoubleQuote.kt.after @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return c == '"' } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringSingleQuote.kt b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringSingleQuote.kt index b5c2251c3b06..4df2d5a60728 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringSingleQuote.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringSingleQuote.kt @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return c == "'" } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringSingleQuote.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringSingleQuote.kt.after index 84bd0002065a..ef0b11254c5c 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringSingleQuote.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/equalityNotApplicable/charLiteralConversion/charEqStringSingleQuote.kt.after @@ -3,4 +3,4 @@ fun test(c: Char): Boolean { return c == '\'' } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/cannotConvertStringToCharLiteral.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/cannotConvertStringToCharLiteral.kt new file mode 100644 index 000000000000..10988ea978f7 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/cannotConvertStringToCharLiteral.kt @@ -0,0 +1,5 @@ +// "Convert string to character literal" "false" +// ERROR: Type mismatch: inferred type is String but Int was expected +fun bar(): Int { + return "a" +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt new file mode 100644 index 000000000000..9509fb505cd2 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt @@ -0,0 +1,8 @@ +// "Convert string to character literal" "true" +// ERROR: A 'return' expression required in a function with a block body ('{...}') +fun bar(): Char { + val c: Char + c = "." +} +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt.after new file mode 100644 index 000000000000..95013d34d149 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt.after @@ -0,0 +1,8 @@ +// "Convert string to character literal" "true" +// ERROR: A 'return' expression required in a function with a block body ('{...}') +fun bar(): Char { + val c: Char + c = '.' +} +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringToCharLiteral.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt similarity index 56% rename from plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringToCharLiteral.kt rename to plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt index f0169a7fb013..8beca1a2463a 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringToCharLiteral.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt @@ -3,4 +3,4 @@ fun bar(): Char { return "a" } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringToCharLiteral.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt.after similarity index 56% rename from plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringToCharLiteral.kt.after rename to plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt.after index 4492a5d7da86..5e59cd4decdc 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringToCharLiteral.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt.after @@ -3,4 +3,4 @@ fun bar(): Char { return 'a' } // FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix -/* IGNORE_K2 */ \ No newline at end of file +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt new file mode 100644 index 000000000000..ec738c73539e --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt @@ -0,0 +1,6 @@ +// "Convert string to character literal" "true" +fun foo() { + val c: Char = "." +} +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt.after new file mode 100644 index 000000000000..7dfc94cbc697 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt.after @@ -0,0 +1,6 @@ +// "Convert string to character literal" "true" +fun foo() { + val c: Char = '.' +} +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt index b50b67098538..2e219b7b00af 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt @@ -4,4 +4,5 @@ fun test(b: Byte, i: Int) { i -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt.after index bef77bec1648..a6185dd25160 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt.after @@ -4,4 +4,5 @@ fun test(b: Byte, i: Int) { i.toByte() -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt index 8263486023cd..60a0ba5a439a 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt @@ -7,4 +7,5 @@ fun test(i: Int) { } fun foo(): String = TODO() -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ChangeCallableReturnTypeFix$ForCalled \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ChangeCallableReturnTypeFix$ForCalled +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt.after index 26f8c5a5ca87..202fec2f87e6 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt.after @@ -7,4 +7,5 @@ fun test(i: Int) { } fun foo(): Int = TODO() -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ChangeCallableReturnTypeFix$ForCalled \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ChangeCallableReturnTypeFix$ForCalled +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt index 002336cb6748..054eaf865c3c 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt @@ -4,4 +4,5 @@ fun test(c: Char) { "." -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt.after index bd4c30cb3a38..7d4a98dd96bf 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt.after @@ -4,4 +4,5 @@ fun test(c: Char) { '.' -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt index b743961b2086..adfd4b7e3dc3 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt @@ -4,4 +4,5 @@ fun test(b: Byte, i: Int) { b -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt.after index d3cd887b401a..3407ae69c4cd 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt.after @@ -4,4 +4,5 @@ fun test(b: Byte, i: Int) { b.toInt() -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt index 2b336263dd80..c8c8ab897556 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt @@ -4,4 +4,5 @@ fun test(s: String, i: Int) { i -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddToStringFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddToStringFix +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt.after index fa9a976bfd97..b79143a06227 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt.after @@ -4,4 +4,5 @@ fun test(s: String, i: Int) { i.toString() -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddToStringFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddToStringFix +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt index f03ab3541f21..890d1efb2537 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt @@ -5,4 +5,5 @@ fun test(ints: List, i: Int) { i -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.WrapWithCollectionLiteralCallFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.WrapWithCollectionLiteralCallFix +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt.after index 95b120412566..8dd6414d8a2b 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt.after @@ -5,4 +5,5 @@ fun test(ints: List, i: Int) { listOf(i) -> {} } } -// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.WrapWithCollectionLiteralCallFix \ No newline at end of file +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.WrapWithCollectionLiteralCallFix +/* IGNORE_K2 */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt new file mode 100644 index 000000000000..a300338aeb75 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt @@ -0,0 +1,8 @@ +// "Convert string to character literal" "true" +fun foo(x: Char) {} + +fun bar() { + foo(".") +} +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt.after new file mode 100644 index 000000000000..9aec37265f16 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt.after @@ -0,0 +1,8 @@ +// "Convert string to character literal" "true" +fun foo(x: Char) {} + +fun bar() { + foo('.') +} +// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix +// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix \ 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 cef7388bde1f..c730b29d20d2 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 @@ -46,6 +46,7 @@ internal fun MutableTWorkspace.generateK2FixTests() { model("$idea/quickfix/typeAddition", pattern = pattern) model("$idea/quickfix/typeMismatch/casts", pattern = pattern) model("$idea/quickfix/typeMismatch/componentFunctionReturnTypeMismatch", pattern = pattern) + model("$idea/quickfix/typeMismatch/incompatibleTypes", pattern = pattern) model("$idea/quickfix/typeMismatch/numberConversion", pattern = pattern) model("$idea/quickfix/typeMismatch/parameterTypeMismatch", pattern = pattern) model("$idea/quickfix/typeMismatch/typeMismatchOnReturnedExpression", pattern = pattern)