From d89947bd5ac49276f6ab001929eac086d18e7121 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Fri, 28 Sep 2018 23:54:36 +0900 Subject: [PATCH] "Convert put to assignment": don't report on 'super' #KT-27146 Fixed --- .../inspections/ReplacePutWithAssignmentInspection.kt | 2 ++ .../replacePutWithAssignment/putOnSuper.kt | 8 ++++++++ .../idea/inspections/LocalInspectionTestGenerated.java | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 idea/testData/inspectionsLocal/replacePutWithAssignment/putOnSuper.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplacePutWithAssignmentInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplacePutWithAssignmentInspection.kt index 12f04718ef9..7f6c93e2cbd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplacePutWithAssignmentInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplacePutWithAssignmentInspection.kt @@ -38,6 +38,8 @@ class ReplacePutWithAssignmentInspection : AbstractApplicabilityBasedInspection< ) { override fun isApplicable(element: KtDotQualifiedExpression): Boolean { + if (element.receiverExpression is KtSuperExpression) return false + val callExpression = element.callExpression if (callExpression?.valueArguments?.size != 2) return false diff --git a/idea/testData/inspectionsLocal/replacePutWithAssignment/putOnSuper.kt b/idea/testData/inspectionsLocal/replacePutWithAssignment/putOnSuper.kt new file mode 100644 index 00000000000..a4541eace82 --- /dev/null +++ b/idea/testData/inspectionsLocal/replacePutWithAssignment/putOnSuper.kt @@ -0,0 +1,8 @@ +// PROBLEM: none +// RUNTIME_WITH_FULL_JDK + +class Test : java.util.LinkedHashMap() { + fun test() { + super.put("foo", "bar") + } +} \ 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 94c9a6d9b84..a78aad621af 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -5071,6 +5071,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/replacePutWithAssignment/putOnParameter.kt"); } + @TestMetadata("putOnSuper.kt") + public void testPutOnSuper() throws Exception { + runTest("idea/testData/inspectionsLocal/replacePutWithAssignment/putOnSuper.kt"); + } + @TestMetadata("putOnThis.kt") public void testPutOnThis() throws Exception { runTest("idea/testData/inspectionsLocal/replacePutWithAssignment/putOnThis.kt");