diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ImplicitThisInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ImplicitThisInspection.kt index c0d751f50c3..bdff8f012e6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ImplicitThisInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ImplicitThisInspection.kt @@ -32,6 +32,7 @@ class ImplicitThisInspection : AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean) = object : KtVisitorVoid() { override fun visitSimpleNameExpression(expression: KtSimpleNameExpression) { if (expression !is KtNameReferenceExpression) return + if (expression.parent is KtThisExpression) return if (expression.isSelectorOfDotQualifiedExpression()) return val parent = expression.parent if (parent is KtCallExpression && parent.isSelectorOfDotQualifiedExpression()) return diff --git a/idea/testData/inspectionsLocal/implicitThis/already.kt b/idea/testData/inspectionsLocal/implicitThis/already.kt new file mode 100644 index 00000000000..30012597691 --- /dev/null +++ b/idea/testData/inspectionsLocal/implicitThis/already.kt @@ -0,0 +1,4 @@ +// PROBLEM: none + +class Your(val x: Int) +fun Your.foo() = this.x \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 844cedcd544..fc40139b995 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -582,45 +582,6 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } - @TestMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ImplicitNullableNothingType extends AbstractLocalInspectionTest { - public void testAllFilesPresentInImplicitNullableNothingType() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/ImplicitNullableNothingType"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("final.kt") - public void testFinal() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/final.kt"); - doTest(fileName); - } - - @TestMetadata("function.kt") - public void testFunction() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/function.kt"); - doTest(fileName); - } - - @TestMetadata("top.kt") - public void testTop() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/top.kt"); - doTest(fileName); - } - - @TestMetadata("val.kt") - public void testVal() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/val.kt"); - doTest(fileName); - } - - @TestMetadata("variable.kt") - public void testVariable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/variable.kt"); - doTest(fileName); - } - } - @TestMetadata("idea/testData/inspectionsLocal/explicitThis") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -714,6 +675,45 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } + @TestMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ImplicitNullableNothingType extends AbstractLocalInspectionTest { + public void testAllFilesPresentInImplicitNullableNothingType() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/ImplicitNullableNothingType"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("final.kt") + public void testFinal() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/final.kt"); + doTest(fileName); + } + + @TestMetadata("function.kt") + public void testFunction() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/function.kt"); + doTest(fileName); + } + + @TestMetadata("top.kt") + public void testTop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/top.kt"); + doTest(fileName); + } + + @TestMetadata("val.kt") + public void testVal() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/val.kt"); + doTest(fileName); + } + + @TestMetadata("variable.kt") + public void testVariable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/ImplicitNullableNothingType/variable.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/inspectionsLocal/implicitThis") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -722,6 +722,12 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/implicitThis"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("already.kt") + public void testAlready() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/implicitThis/already.kt"); + doTest(fileName); + } + @TestMetadata("function.kt") public void testFunction() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/implicitThis/function.kt");