提交 ba5e643c 编写于 作者: T Toshiaki Kameyama 提交者: Dmitry Gridin

Redundant qualifier name: fix false positive with same name variable

#KT-39200 Fixed
上级 bf26d87e
...@@ -61,6 +61,7 @@ class RemoveRedundantQualifierNameInspection : AbstractKotlinInspection(), Clean ...@@ -61,6 +61,7 @@ class RemoveRedundantQualifierNameInspection : AbstractKotlinInspection(), Clean
val expressionParent = expression.parent val expressionParent = expression.parent
if (expressionParent is KtDotQualifiedExpression || expressionParent is KtPackageDirective || expressionParent is KtImportDirective) return if (expressionParent is KtDotQualifiedExpression || expressionParent is KtPackageDirective || expressionParent is KtImportDirective) return
val expressionForAnalyze = expression.firstExpressionWithoutReceiver() ?: return val expressionForAnalyze = expression.firstExpressionWithoutReceiver() ?: return
if (expressionForAnalyze.selectorExpression?.text == expressionParent.getNonStrictParentOfType<KtProperty>()?.name) return
val originalExpression: KtExpression = expressionForAnalyze.parent as? KtClassLiteralExpression ?: expressionForAnalyze val originalExpression: KtExpression = expressionForAnalyze.parent as? KtClassLiteralExpression ?: expressionForAnalyze
......
// PROBLEM: none
sealed class Foo {
object BAR : Foo()
companion object {
val BAR: Foo = <caret>Foo.BAR
}
}
\ No newline at end of file
// PROBLEM: none
// WITH_RUNTIME
sealed class Foo {
object BAR : Foo()
companion object {
val BAR: Foo by lazy { <caret>Foo.BAR }
}
}
\ No newline at end of file
...@@ -9521,6 +9521,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { ...@@ -9521,6 +9521,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableOuterClass.kt"); 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") @TestMetadata("notApplicableThis.kt")
public void testNotApplicableThis() throws Exception { public void testNotApplicableThis() throws Exception {
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableThis.kt"); runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableThis.kt");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册