Constructor parameter is never used as a property: do not report if parameter is used as a reference

#KT-34686 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-01-22 19:01:31 +09:00
committed by Mikhail Glukhikh
parent 59f70a912a
commit 1ba8b52856
2 changed files with 6 additions and 1 deletions
@@ -99,7 +99,7 @@ class CanBeParameterInspection : AbstractKotlinInspection() {
// Find all references and check them
val references = ReferencesSearch.search(parameter, restrictedScope)
if (references.none()) return
if (references.any { it.usedAsPropertyIn(klass) }) return
if (references.any { it.element.parent is KtCallableReferenceExpression || it.usedAsPropertyIn(klass) }) return
holder.registerProblem(
valOrVar,
"Constructor parameter is never used as a property",
+5
View File
@@ -151,3 +151,8 @@ class UsedInObjectSuper(val bar456: String) {
object : Base1(bar456) {}
}
}
// NO
class Foo(<caret>var baz: String) {
var bar = ::baz
}