diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index 3bbec3036e3..79eb91c7400 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -145,6 +145,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() { is KtSecondaryConstructor -> "Constructor is never used" is KtProperty, is KtParameter -> "Property ''$name'' is never used" is KtTypeParameter -> "Type parameter ''$name'' is never used" + is KtTypeAlias -> "Type alias ''$name'' is never used" else -> return } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt index ca1bbc48b96..678162e22d7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/utils.kt @@ -49,6 +49,7 @@ fun PsiElement.canDeleteElement(): Boolean { || this is PsiClass || this is KtProperty || this is KtTypeParameter + || this is KtTypeAlias } fun PsiElement.removeOverrideModifier() { diff --git a/idea/testData/inspections/unusedSymbol/typeAlias/inspectionData/expected.xml b/idea/testData/inspections/unusedSymbol/typeAlias/inspectionData/expected.xml new file mode 100644 index 00000000000..5da121d8e3a --- /dev/null +++ b/idea/testData/inspections/unusedSymbol/typeAlias/inspectionData/expected.xml @@ -0,0 +1,18 @@ + + + test.kt + 4 + light_idea_test_case + + Unused symbol + Type alias ''YourString'' is never used + + + test.kt + 6 + light_idea_test_case + + Unused symbol + Property ''ms'' is never used + + diff --git a/idea/testData/inspections/unusedSymbol/typeAlias/inspectionData/inspections.test b/idea/testData/inspections/unusedSymbol/typeAlias/inspectionData/inspections.test new file mode 100644 index 00000000000..02aea1c357e --- /dev/null +++ b/idea/testData/inspections/unusedSymbol/typeAlias/inspectionData/inspections.test @@ -0,0 +1 @@ +// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection diff --git a/idea/testData/inspections/unusedSymbol/typeAlias/test.kt b/idea/testData/inspections/unusedSymbol/typeAlias/test.kt new file mode 100644 index 00000000000..3ca00d3a817 --- /dev/null +++ b/idea/testData/inspections/unusedSymbol/typeAlias/test.kt @@ -0,0 +1,6 @@ +typealias MyString = String + +// unused +typealias YourString = String + +val ms: MyString = "" \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java index 65b33c2f867..89cd7f96ab9 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java @@ -413,6 +413,12 @@ public class InspectionTestGenerated extends AbstractInspectionTest { doTest(fileName); } + @TestMetadata("unusedSymbol/typeAlias/inspectionData/inspections.test") + public void testUnusedSymbol_typeAlias_inspectionData_Inspections_test() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspections/unusedSymbol/typeAlias/inspectionData/inspections.test"); + doTest(fileName); + } + @TestMetadata("unusedSymbol/typeParameter/inspectionData/inspections.test") public void testUnusedSymbol_typeParameter_inspectionData_Inspections_test() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspections/unusedSymbol/typeParameter/inspectionData/inspections.test");