From aeff9fcae8b1e9ed8df1d3e75bd5eb06d4275534 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 29 Mar 2018 12:44:11 +0300 Subject: [PATCH] Optimization: RedundantCompanionReferenceInspection GitOrigin-RevId: 673a1d40a06b718b6961d67a0b16bb80c8806235 --- .../idea/inspections/RedundantCompanionReferenceInspection.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantCompanionReferenceInspection.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantCompanionReferenceInspection.kt index 9c810d5626e4..175728edbfc6 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantCompanionReferenceInspection.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantCompanionReferenceInspection.kt @@ -22,13 +22,13 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils class RedundantCompanionReferenceInspection : AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { return referenceExpressionVisitor(fun(expression) { + val parent = expression.parent as? KtDotQualifiedExpression ?: return + if (expression == parent.selectorExpression && parent.parent !is KtDotQualifiedExpression) return val descriptor = (expression.mainReference.resolve() as? KtObjectDeclaration)?.descriptor ?: return if (!DescriptorUtils.isCompanionObject(descriptor)) return - val parent = expression.parent as? KtDotQualifiedExpression ?: return if (expression == parent.receiverExpression && expression.text == descriptor.containingDeclaration?.name?.asString()) return - if (expression == parent.selectorExpression && parent.parent !is KtDotQualifiedExpression) return holder.registerProblem( expression,