Don't report unused symbol if secondary constructor used

#KT-6997 Fixed
This commit is contained in:
Denis Zharkov
2015-03-11 18:24:26 +03:00
committed by Alexey Sedunov
parent c6290efbe2
commit d1308ebf84
9 changed files with 46 additions and 1 deletions
@@ -50,7 +50,7 @@ public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean {
if (this is JetReference) {
return targets.any {
it is PsiMethod && it.isConstructor() && it.getContainingClass() == unwrappedCandidate
it.isConstructorOf(unwrappedCandidate)
|| it is JetObjectDeclaration && it.isCompanion() && it.getNonStrictParentOfType<JetClass>() == unwrappedCandidate
}
}
@@ -68,6 +68,12 @@ public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean {
return false
}
private fun PsiElement.isConstructorOf(unwrappedCandidate: PsiElement) =
// call to Java constructor
(this is PsiMethod && isConstructor() && getContainingClass() == unwrappedCandidate) ||
// call to Kotlin constructor
(this is JetSecondaryConstructor && getStrictParentOfType<JetClass>() == unwrappedCandidate)
fun AbstractJetReference<out JetExpression>.renameImplicitConventionalCall(newName: String?): JetExpression {
if (newName == null) return expression