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