Redundant companion reference: Fix false negative in enum entry #KT-27861 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
07ca958ff0
commit
23b9889ebb
-1
@@ -41,7 +41,6 @@ class RedundantCompanionReferenceInspection : AbstractKotlinInspection() {
|
|||||||
|
|
||||||
val containingClass = objectDeclaration.containingClass() ?: return
|
val containingClass = objectDeclaration.containingClass() ?: return
|
||||||
if (expression.containingClass() != containingClass && expression == parent.receiverExpression) return
|
if (expression.containingClass() != containingClass && expression == parent.receiverExpression) return
|
||||||
if (parent.getStrictParentOfType<KtEnumEntry>()?.containingClass() == containingClass) return
|
|
||||||
val containingClassDescriptor = containingClass.descriptor as? ClassDescriptor ?: return
|
val containingClassDescriptor = containingClass.descriptor as? ClassDescriptor ?: return
|
||||||
val selectorDescriptor = selectorExpression?.getCallableDescriptor()
|
val selectorDescriptor = selectorExpression?.getCallableDescriptor()
|
||||||
when (selectorDescriptor) {
|
when (selectorDescriptor) {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
enum class E(val value: String) {
|
||||||
|
E1(E.<caret>Companion.foo);
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val foo = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
enum class E(val value: String) {
|
||||||
|
E1(E.foo);
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val foo = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -3994,6 +3994,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/redundantCompanionReference/inEnumEntry2.kt");
|
runTest("idea/testData/inspectionsLocal/redundantCompanionReference/inEnumEntry2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inEnumEntry3.kt")
|
||||||
|
public void testInEnumEntry3() throws Exception {
|
||||||
|
runTest("idea/testData/inspectionsLocal/redundantCompanionReference/inEnumEntry3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("methodArgument.kt")
|
@TestMetadata("methodArgument.kt")
|
||||||
public void testMethodArgument() throws Exception {
|
public void testMethodArgument() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/redundantCompanionReference/methodArgument.kt");
|
runTest("idea/testData/inspectionsLocal/redundantCompanionReference/methodArgument.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user