diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt index c6616b05e0b..08ead9083e2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSamConstructorInspection.kt @@ -51,7 +51,7 @@ class RedundantSamConstructorInspection : AbstractKotlinInspection() { if (single != null) { val calleeExpression = single.calleeExpression ?: return val problemDescriptor = holder.manager.createProblemDescriptor( - calleeExpression, + single.getQualifiedExpressionForSelectorOrThis(), single.typeArgumentList ?: calleeExpression, "Redundant SAM-constructor", ProblemHighlightType.LIKE_UNUSED_SYMBOL, diff --git a/idea/testData/inspectionsLocal/redundantSamConstructor/.inspection b/idea/testData/inspectionsLocal/redundantSamConstructor/.inspection new file mode 100644 index 00000000000..87023e85c21 --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantSamConstructor/.inspection @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.inspections.RedundantSamConstructorInspection \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.1.java b/idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.1.java new file mode 100644 index 00000000000..74181972ca4 --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.1.java @@ -0,0 +1,8 @@ +public class Foo { + public interface Bar { + void baz(); + } + public static void foo(Bar bar) { + bar.baz(); + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.kt b/idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.kt new file mode 100644 index 00000000000..fdf3743c30f --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.kt @@ -0,0 +1,3 @@ +fun test() { + Foo.foo(Foo.Bar { }) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.kt.after b/idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.kt.after new file mode 100644 index 00000000000..14f1d949f12 --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.kt.after @@ -0,0 +1,3 @@ +fun test() { + Foo.foo({ }) +} \ 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 3ee9733ea14..cdff9898ffa 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -3117,6 +3117,21 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } + @TestMetadata("idea/testData/inspectionsLocal/redundantSamConstructor") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class RedundantSamConstructor extends AbstractLocalInspectionTest { + public void testAllFilesPresentInRedundantSamConstructor() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/redundantSamConstructor"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("nestedInterface.kt") + public void testNestedInterface() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/inspectionsLocal/redundantSemicolon") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)