Redundant qualifier name: fix false positive with same name variable
#KT-39200 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
bf26d87ee9
commit
ba5e643cb2
+1
@@ -61,6 +61,7 @@ class RemoveRedundantQualifierNameInspection : AbstractKotlinInspection(), Clean
|
||||
val expressionParent = expression.parent
|
||||
if (expressionParent is KtDotQualifiedExpression || expressionParent is KtPackageDirective || expressionParent is KtImportDirective) return
|
||||
val expressionForAnalyze = expression.firstExpressionWithoutReceiver() ?: return
|
||||
if (expressionForAnalyze.selectorExpression?.text == expressionParent.getNonStrictParentOfType<KtProperty>()?.name) return
|
||||
|
||||
val originalExpression: KtExpression = expressionForAnalyze.parent as? KtClassLiteralExpression ?: expressionForAnalyze
|
||||
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
sealed class Foo {
|
||||
object BAR : Foo()
|
||||
|
||||
companion object {
|
||||
val BAR: Foo = <caret>Foo.BAR
|
||||
}
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
sealed class Foo {
|
||||
object BAR : Foo()
|
||||
|
||||
companion object {
|
||||
val BAR: Foo by lazy { <caret>Foo.BAR }
|
||||
}
|
||||
}
|
||||
+10
@@ -9521,6 +9521,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableOuterClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableSameNameVariable.kt")
|
||||
public void testNotApplicableSameNameVariable() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableSameNameVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableSameNameVariable2.kt")
|
||||
public void testNotApplicableSameNameVariable2() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableSameNameVariable2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableThis.kt")
|
||||
public void testNotApplicableThis() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableThis.kt");
|
||||
|
||||
Reference in New Issue
Block a user