From 64ae9af3a4713a2ee22fbc6314afa5ed269f95f6 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 25 Apr 2016 15:07:03 +0300 Subject: [PATCH] Can be parameter inspection: use in selector position is now always handled as "property use" --- .../kotlin/idea/inspections/CanBeParameterInspection.kt | 4 ++-- idea/testData/inspections/canBeParameter/test.kt | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/CanBeParameterInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/CanBeParameterInspection.kt index f394324d112..06741daa233 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/CanBeParameterInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/CanBeParameterInspection.kt @@ -41,10 +41,10 @@ class CanBeParameterInspection : AbstractKotlinInspection() { private fun PsiReference.usedAsPropertyIn(klass: KtClass): Boolean { if (this !is KtSimpleNameReference) return true val nameExpression = element - // this.x + // receiver.x val parent = element.parent if (parent is KtQualifiedExpression) { - if (parent.receiverExpression is KtThisExpression) return true + if (parent.selectorExpression == element) return true } // x += something if (parent is KtBinaryExpression && diff --git a/idea/testData/inspections/canBeParameter/test.kt b/idea/testData/inspections/canBeParameter/test.kt index 87237af46e3..5818c1d46bf 100644 --- a/idea/testData/inspections/canBeParameter/test.kt +++ b/idea/testData/inspections/canBeParameter/test.kt @@ -116,4 +116,8 @@ class UsedInDelegate(val x: Int) { val y: Int by lazy { x * x } +} +// NO +class UsedInParent(val x: UsedInParent?) { + val y = x?.x } \ No newline at end of file