Fix false positive 'Remove redundant qualifier name' for property
#KT-31112 Fixed
This commit is contained in:
+1
-1
@@ -59,7 +59,7 @@ class RemoveRedundantQualifierNameInspection : AbstractKotlinInspection(), Clean
|
|||||||
}
|
}
|
||||||
|
|
||||||
private tailrec fun KtDotQualifiedExpression.firstExpressionWithoutReceiver(): KtDotQualifiedExpression? =
|
private tailrec fun KtDotQualifiedExpression.firstExpressionWithoutReceiver(): KtDotQualifiedExpression? =
|
||||||
if ((getQualifiedElementSelector()?.mainReference?.resolve() as? KtFunction)?.receiverTypeReference == null) this
|
if ((getQualifiedElementSelector()?.mainReference?.resolve() as? KtCallableDeclaration)?.receiverTypeReference == null) this
|
||||||
else (receiverExpression as? KtDotQualifiedExpression)?.firstExpressionWithoutReceiver()
|
else (receiverExpression as? KtDotQualifiedExpression)?.firstExpressionWithoutReceiver()
|
||||||
|
|
||||||
private tailrec fun <T : KtElement> T.firstApplicableExpression(validator: T.() -> T?, generator: T.() -> T?): T? =
|
private tailrec fun <T : KtElement> T.firstApplicableExpression(validator: T.() -> T?, generator: T.() -> T?): T? =
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package inspector.p30879
|
||||||
|
import inspector.p30879.C.G
|
||||||
|
|
||||||
|
val <T> T.letVar: Int; get() = 0
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
C<caret>.G.letVar
|
||||||
|
}
|
||||||
|
|
||||||
|
class B { object G }
|
||||||
|
class C { object G }
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package inspector.p30879
|
||||||
|
import inspector.p30879.C.G
|
||||||
|
|
||||||
|
val <T> T.letVar: Int; get() = 0
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
G.letVar
|
||||||
|
}
|
||||||
|
|
||||||
|
class B { object G }
|
||||||
|
class C { object G }
|
||||||
Vendored
+13
@@ -0,0 +1,13 @@
|
|||||||
|
// PROBLEM: none
|
||||||
|
|
||||||
|
package inspector.p30879
|
||||||
|
import inspector.p30879.B.G
|
||||||
|
|
||||||
|
val <T> T.letVar: Int; get() = 0
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
C<caret>.G.letVar
|
||||||
|
}
|
||||||
|
|
||||||
|
class B { object G }
|
||||||
|
class C { object G }
|
||||||
+10
@@ -6275,6 +6275,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/asReceiver.kt");
|
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/asReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("asReceiverProperty.kt")
|
||||||
|
public void testAsReceiverProperty() throws Exception {
|
||||||
|
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/asReceiverProperty.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("companionCollision.kt")
|
@TestMetadata("companionCollision.kt")
|
||||||
public void testCompanionCollision() throws Exception {
|
public void testCompanionCollision() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/companionCollision.kt");
|
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/companionCollision.kt");
|
||||||
@@ -6400,6 +6405,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableAsReceiver.kt");
|
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableAsReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("notApplicableAsReceiverProperty.kt")
|
||||||
|
public void testNotApplicableAsReceiverProperty() throws Exception {
|
||||||
|
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableAsReceiverProperty.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("notApplicableCollisionTopLevelClass.kt")
|
@TestMetadata("notApplicableCollisionTopLevelClass.kt")
|
||||||
public void testNotApplicableCollisionTopLevelClass() throws Exception {
|
public void testNotApplicableCollisionTopLevelClass() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableCollisionTopLevelClass.kt");
|
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/notApplicableCollisionTopLevelClass.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user