From 23488fac56e5cdef684b42cbcfb917eb903e92b2 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 29 Mar 2018 12:44:11 +0300 Subject: [PATCH] Optimization: RedundantCompanionReferenceInspection --- .../idea/inspections/RedundantCompanionReferenceInspection.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantCompanionReferenceInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantCompanionReferenceInspection.kt index 9c810d5626e..175728edbfc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantCompanionReferenceInspection.kt +++ b/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,