diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtEnumEntrySuperclassReferenceExpression.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtEnumEntrySuperclassReferenceExpression.kt index 69fff055ca0..1bc70ecc8b8 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtEnumEntrySuperclassReferenceExpression.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtEnumEntrySuperclassReferenceExpression.kt @@ -36,8 +36,8 @@ class KtEnumEntrySuperclassReferenceExpression : super(stub, KtStubElementTypes.ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION) // It is the owner enum class (not an enum entry but the whole enum) - private val referencedElement: KtClass - get() = calcReferencedElement()!! + private val referencedElement: KtClass? + get() = calcReferencedElement() private fun calcReferencedElement(): KtClass? { val owner = this.getStrictParentOfType() @@ -54,15 +54,15 @@ class KtEnumEntrySuperclassReferenceExpression : } override fun getReferencedNameAsName(): Name { - return referencedElement.name?.let { Name.identifier(it) } ?: SpecialNames.NO_NAME_PROVIDED + return referencedElement?.name?.let { Name.identifier(it) } ?: SpecialNames.NO_NAME_PROVIDED } override fun getReferencedNameElement(): PsiElement { - return referencedElement + return referencedElement!! } override fun getIdentifier(): PsiElement? { - return referencedElement.nameIdentifier + return referencedElement?.nameIdentifier } override fun getReferencedNameElementType(): IElementType { diff --git a/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/expected.xml b/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/expected.xml index 069d6819617..6fae53e378b 100644 --- a/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/expected.xml +++ b/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/expected.xml @@ -223,4 +223,14 @@ Unnecessary type argument Remove explicit type arguments + + + kt29735.kt + 4 + light_idea_test_case + kt29735 + + Unnecessary type argument + Remove explicit type arguments + \ No newline at end of file diff --git a/idea/testData/intentions/removeExplicitTypeArguments/kt29735.kt b/idea/testData/intentions/removeExplicitTypeArguments/kt29735.kt new file mode 100644 index 00000000000..bf428cbd618 --- /dev/null +++ b/idea/testData/intentions/removeExplicitTypeArguments/kt29735.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +enum class A(val strings: List) { + B(listOfing>("")) +} \ No newline at end of file diff --git a/idea/testData/intentions/removeExplicitTypeArguments/kt29735.kt.after b/idea/testData/intentions/removeExplicitTypeArguments/kt29735.kt.after new file mode 100644 index 00000000000..e4a665da99f --- /dev/null +++ b/idea/testData/intentions/removeExplicitTypeArguments/kt29735.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +enum class A(val strings: List) { + B(listOf("")) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index ffc098cf01e..e13e89a46ad 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -14492,6 +14492,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest { runTest("idea/testData/intentions/removeExplicitTypeArguments/insideOtherCall.kt"); } + @TestMetadata("kt29735.kt") + public void testKt29735() throws Exception { + runTest("idea/testData/intentions/removeExplicitTypeArguments/kt29735.kt"); + } + @TestMetadata("kt31441.kt") public void testKt31441() throws Exception { runTest("idea/testData/intentions/removeExplicitTypeArguments/kt31441.kt");