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:
committed by
Mikhail Glukhikh
parent
59f70a912a
commit
1ba8b52856
@@ -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",
|
||||
|
||||
@@ -151,3 +151,8 @@ class UsedInObjectSuper(val bar456: String) {
|
||||
object : Base1(bar456) {}
|
||||
}
|
||||
}
|
||||
|
||||
// NO
|
||||
class Foo(<caret>var baz: String) {
|
||||
var bar = ::baz
|
||||
}
|
||||
Reference in New Issue
Block a user