From 103f8300fb31fc7fbd410fd911b519e8fe52591d Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 24 Feb 2016 18:02:30 +0100 Subject: [PATCH] don't show "Change type arguments" fix when there's nothing to change #KT-11178 Fixed --- .../kotlin/idea/quickfix/ChangeToStarProjectionFix.kt | 5 ++++- .../addStarProjections/cast/uncheckedCastOnTypeParameter.kt | 5 +++++ .../kotlin/idea/quickfix/QuickFixTestGenerated.java | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 idea/testData/quickfix/addStarProjections/cast/uncheckedCastOnTypeParameter.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeToStarProjectionFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeToStarProjectionFix.kt index 1ae9e3d99b2..7531eff7b03 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeToStarProjectionFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeToStarProjectionFix.kt @@ -38,7 +38,10 @@ class ChangeToStarProjectionFix(element: KtTypeElement) : KotlinQuickFixAction()?.right ?: diagnostic.psiElement.getNonStrictParentOfType() val typeElement = typeReference?.typeElement ?: return null - return ChangeToStarProjectionFix(typeElement) + if (typeElement.typeArgumentsAsTypes.isNotEmpty()) { + return ChangeToStarProjectionFix(typeElement) + } + return null } } } diff --git a/idea/testData/quickfix/addStarProjections/cast/uncheckedCastOnTypeParameter.kt b/idea/testData/quickfix/addStarProjections/cast/uncheckedCastOnTypeParameter.kt new file mode 100644 index 00000000000..9b897c34b44 --- /dev/null +++ b/idea/testData/quickfix/addStarProjections/cast/uncheckedCastOnTypeParameter.kt @@ -0,0 +1,5 @@ +// "Change type arguments to <>" "false" +// ACTION: Convert to expression body +fun get(column: String, map: Map): T { + return map[column] as T +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 6474ca97e74..5e2d73b549c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -413,6 +413,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addStarProjections/cast/changeToStarProjectionNullable.kt"); doTest(fileName); } + + @TestMetadata("uncheckedCastOnTypeParameter.kt") + public void testUncheckedCastOnTypeParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addStarProjections/cast/uncheckedCastOnTypeParameter.kt"); + doTest(fileName); + } } @TestMetadata("idea/testData/quickfix/addStarProjections/checkType")