diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java index fb2b6e6b70c..f2b771605b7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java @@ -87,6 +87,7 @@ public class QuickFixRegistrar { QuickFixes.factories.put(USELESS_CAST_STATIC_ASSERT_IS_FINE, ReplaceOperationInBinaryExpressionFix.createChangeCastToStaticAssertFactory()); QuickFixes.factories.put(USELESS_CAST, RemoveRightPartOfBinaryExpressionFix.createRemoveCastFactory()); + QuickFixes.factories.put(USELESS_CAST_STATIC_ASSERT_IS_FINE, RemoveRightPartOfBinaryExpressionFix.createRemoveCastFactory()); JetSingleIntentionActionFactory changeAccessorTypeFactory = ChangeAccessorTypeFix.createFactory(); QuickFixes.factories.put(WRONG_SETTER_PARAMETER_TYPE, changeAccessorTypeFactory); diff --git a/idea/testData/quickfix/expressions/afterRemoveUselessCast.kt b/idea/testData/quickfix/expressions/afterRemoveUselessCast.kt new file mode 100644 index 00000000000..9a446bec737 --- /dev/null +++ b/idea/testData/quickfix/expressions/afterRemoveUselessCast.kt @@ -0,0 +1,4 @@ +// "Remove cast" "true" +fun foo(a: String) { + val b = a +} diff --git a/idea/testData/quickfix/expressions/afterRemoveUselessCastUnderSmartCast.kt b/idea/testData/quickfix/expressions/afterRemoveUselessCastUnderSmartCast.kt new file mode 100644 index 00000000000..8fc23d973e2 --- /dev/null +++ b/idea/testData/quickfix/expressions/afterRemoveUselessCastUnderSmartCast.kt @@ -0,0 +1,7 @@ +// "Remove cast" "true" +fun test(x: Any): String? { + if (x is String) { + return x + } + return null +} diff --git a/idea/testData/quickfix/expressions/afterUselessCast.kt b/idea/testData/quickfix/expressions/afterReplaceUselessCastWithStaticAssert.kt similarity index 100% rename from idea/testData/quickfix/expressions/afterUselessCast.kt rename to idea/testData/quickfix/expressions/afterReplaceUselessCastWithStaticAssert.kt diff --git a/idea/testData/quickfix/expressions/beforeRemoveUselessCast.kt b/idea/testData/quickfix/expressions/beforeRemoveUselessCast.kt new file mode 100644 index 00000000000..9fc01d92119 --- /dev/null +++ b/idea/testData/quickfix/expressions/beforeRemoveUselessCast.kt @@ -0,0 +1,4 @@ +// "Remove cast" "true" +fun foo(a: String) { + val b = a as Any +} diff --git a/idea/testData/quickfix/expressions/beforeRemoveUselessCastUnderSmartCast.kt b/idea/testData/quickfix/expressions/beforeRemoveUselessCastUnderSmartCast.kt new file mode 100644 index 00000000000..49890c41610 --- /dev/null +++ b/idea/testData/quickfix/expressions/beforeRemoveUselessCastUnderSmartCast.kt @@ -0,0 +1,7 @@ +// "Remove cast" "true" +fun test(x: Any): String? { + if (x is String) { + return x as String + } + return null +} diff --git a/idea/testData/quickfix/expressions/beforeUselessCast.kt b/idea/testData/quickfix/expressions/beforeReplaceUselessCastWithStaticAssert.kt similarity index 100% rename from idea/testData/quickfix/expressions/beforeUselessCast.kt rename to idea/testData/quickfix/expressions/beforeReplaceUselessCastWithStaticAssert.kt diff --git a/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/afterNonLocalReturn.kt b/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/afterNonLocalReturnRuntime.kt similarity index 100% rename from idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/afterNonLocalReturn.kt rename to idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/afterNonLocalReturnRuntime.kt diff --git a/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/afterNonLocalReturnWithLabel.kt b/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/afterNonLocalReturnWithLabelRuntime.kt similarity index 100% rename from idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/afterNonLocalReturnWithLabel.kt rename to idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/afterNonLocalReturnWithLabelRuntime.kt diff --git a/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturn.kt b/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnRuntime.kt similarity index 100% rename from idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturn.kt rename to idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnRuntime.kt diff --git a/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnWithLabel.kt b/idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnWithLabelRuntime.kt similarity index 100% rename from idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnWithLabel.kt rename to idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnWithLabelRuntime.kt diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index d7fe78d0b4d..67240ea7412 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -2825,6 +2825,24 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } + @TestMetadata("beforeRemoveUselessCast.kt") + public void testRemoveUselessCast() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeRemoveUselessCast.kt"); + doTest(fileName); + } + + @TestMetadata("beforeRemoveUselessCastUnderSmartCast.kt") + public void testRemoveUselessCastUnderSmartCast() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeRemoveUselessCastUnderSmartCast.kt"); + doTest(fileName); + } + + @TestMetadata("beforeReplaceUselessCastWithStaticAssert.kt") + public void testReplaceUselessCastWithStaticAssert() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeReplaceUselessCastWithStaticAssert.kt"); + doTest(fileName); + } + @TestMetadata("beforeUnnecessaryNonNullAssertion1.kt") public void testUnnecessaryNonNullAssertion1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeUnnecessaryNonNullAssertion1.kt"); @@ -2867,12 +2885,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } - @TestMetadata("beforeUselessCast.kt") - public void testUselessCast() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeUselessCast.kt"); - doTest(fileName); - } - @TestMetadata("beforeUselessCastStaticAssertIsFine.kt") public void testUselessCastStaticAssertIsFine() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/beforeUselessCastStaticAssertIsFine.kt"); @@ -4954,15 +4966,15 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } - @TestMetadata("beforeNonLocalReturn.kt") - public void testNonLocalReturn() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturn.kt"); + @TestMetadata("beforeNonLocalReturnRuntime.kt") + public void testNonLocalReturnRuntime() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnRuntime.kt"); doTest(fileName); } - @TestMetadata("beforeNonLocalReturnWithLabel.kt") - public void testNonLocalReturnWithLabel() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnWithLabel.kt"); + @TestMetadata("beforeNonLocalReturnWithLabelRuntime.kt") + public void testNonLocalReturnWithLabelRuntime() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/beforeNonLocalReturnWithLabelRuntime.kt"); doTest(fileName); }