From 93defed324e2975b66a6febe10f41d48c7a72d8e Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 20 May 2016 14:42:47 +0300 Subject: [PATCH] KT-12302: ABSTRACT_MODIFIER_IN_INTERFACE warning is removed as obsolete --- .../jetbrains/kotlin/diagnostics/Errors.java | 3 --- .../rendering/DefaultErrorMessages.java | 1 - .../kotlin/resolve/DeclarationsChecker.kt | 6 ------ .../diagnostics/tests/AbstractInTrait.kt | 20 +++++++++---------- .../tests/modifiers/privateInInterface.kt | 2 +- .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 1 - idea/testData/checker/Abstract.kt | 18 ++++++++--------- .../quickfix/abstract/redundantAbstract.kt | 4 ---- .../abstract/redundantAbstract.kt.after | 4 ---- .../redundantAbstract.kt | 4 ++++ .../redundantAbstract.kt.after | 4 ++++ .../idea/quickfix/QuickFixTestGenerated.java | 12 +++++------ 12 files changed, 34 insertions(+), 45 deletions(-) delete mode 100644 idea/testData/quickfix/abstract/redundantAbstract.kt delete mode 100644 idea/testData/quickfix/abstract/redundantAbstract.kt.after create mode 100644 idea/testData/quickfix/redundantModalityModifier/redundantAbstract.kt create mode 100644 idea/testData/quickfix/redundantModalityModifier/redundantAbstract.kt.after diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 8475dd3f419..b4e3abd8c45 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -239,9 +239,6 @@ public interface Errors { // Interface-specific - DiagnosticFactory0 ABSTRACT_MODIFIER_IN_INTERFACE = DiagnosticFactory0 - .create(WARNING, ABSTRACT_MODIFIER); - DiagnosticFactory0 CONSTRUCTOR_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0 METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE = DiagnosticFactory0.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index a998c81daf3..d581cccc011 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -158,7 +158,6 @@ public class DefaultErrorMessages { MAP.put(REDUNDANT_ANNOTATION_TARGET, "Redundant annotation target ''{0}''", STRING); MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING); - MAP.put(ABSTRACT_MODIFIER_IN_INTERFACE, "Modifier 'abstract' is redundant in interface"); MAP.put(REDUNDANT_MODIFIER_IN_GETTER, "Visibility modifiers are redundant in getter"); MAP.put(TYPE_PARAMETERS_IN_ENUM, "Enum class cannot have type parameters"); MAP.put(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index 194fcdef296..17f33e7c131 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -518,9 +518,6 @@ class DeclarationsChecker( trace.report(ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS.on(property, property.name ?: "", classDescriptor)) return } - if (classDescriptor.kind == ClassKind.INTERFACE) { - trace.report(ABSTRACT_MODIFIER_IN_INTERFACE.on(property)) - } } if (propertyDescriptor.modality == Modality.ABSTRACT) { @@ -614,9 +611,6 @@ class DeclarationsChecker( if (hasAbstractModifier && !classCanHaveAbstractMembers(containingDescriptor)) { trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.name.asString(), containingDescriptor)) } - if (hasAbstractModifier && inTrait) { - trace.report(ABSTRACT_MODIFIER_IN_INTERFACE.on(function)) - } val hasBody = function.hasBody() if (hasBody && hasAbstractModifier) { trace.report(ABSTRACT_FUNCTION_WITH_BODY.on(function, functionDescriptor)) diff --git a/compiler/testData/diagnostics/tests/AbstractInTrait.kt b/compiler/testData/diagnostics/tests/AbstractInTrait.kt index 30ea1bdc4f6..c09611c7056 100644 --- a/compiler/testData/diagnostics/tests/AbstractInTrait.kt +++ b/compiler/testData/diagnostics/tests/AbstractInTrait.kt @@ -4,29 +4,29 @@ interface MyTrait { //properties val a: Int val a1: Int = 1 - abstract val a2: Int - abstract val a3: Int = 1 + abstract val a2: Int + abstract val a3: Int = 1 var b: Int private set var b1: Int = 0; private set - abstract var b2: Int private set - abstract var b3: Int = 0; private set + abstract var b2: Int private set + abstract var b3: Int = 0; private set var c: Int set(v: Int) { field = v } var c1: Int = 0; set(v: Int) { field = v } - abstract var c2: Int set(v: Int) { field = v } - abstract var c3: Int = 0; set(v: Int) { field = v } + abstract var c2: Int set(v: Int) { field = v } + abstract var c3: Int = 0; set(v: Int) { field = v } val e: Int get() = a val e1: Int = 0; get() = a - abstract val e2: Int get() = a - abstract val e3: Int = 0; get() = a + abstract val e2: Int get() = a + abstract val e3: Int = 0; get() = a //methods fun f() fun g() {} - abstract fun h() - abstract fun j() {} + abstract fun h() + abstract fun j() {} //property accessors var i: Int abstract get abstract set diff --git a/compiler/testData/diagnostics/tests/modifiers/privateInInterface.kt b/compiler/testData/diagnostics/tests/modifiers/privateInInterface.kt index 8cf64c627ae..2201fb23911 100644 --- a/compiler/testData/diagnostics/tests/modifiers/privateInInterface.kt +++ b/compiler/testData/diagnostics/tests/modifiers/privateInInterface.kt @@ -1,6 +1,6 @@ interface My { private val x: Int - private abstract val xx: Int + private abstract val xx: Int private val xxx: Int get() = 0 final val y: Int diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 2de775f1105..2c69b3faeee 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -101,7 +101,6 @@ class QuickFixRegistrar : QuickFixContributor { val removeRedundantModifierFactory = RemoveModifierFix.createRemoveModifierFactory(true) REDUNDANT_MODIFIER.registerFactory(removeRedundantModifierFactory) - ABSTRACT_MODIFIER_IN_INTERFACE.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD, true)) REDUNDANT_PROJECTION.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(true)) INCOMPATIBLE_MODIFIERS.registerFactory(RemoveModifierFix.createRemoveModifierFactory(false)) diff --git a/idea/testData/checker/Abstract.kt b/idea/testData/checker/Abstract.kt index 82692a9dd69..d73175cbd5c 100644 --- a/idea/testData/checker/Abstract.kt +++ b/idea/testData/checker/Abstract.kt @@ -67,29 +67,29 @@ interface MyTrait { val a: Int val a1: Int = 1 - abstract val a2: Int - abstract val a3: Int = 1 + abstract val a2: Int + abstract val a3: Int = 1 var b: Int private set var b1: Int = 0; private set - abstract var b2: Int private set - abstract var b3: Int = 0; private set + abstract var b2: Int private set + abstract var b3: Int = 0; private set var c: Int set(v: Int) { field = v } var c1: Int = 0; set(v: Int) { field = v } - abstract var c2: Int set(v: Int) { field = v } - abstract var c3: Int = 0; set(v: Int) { field = v } + abstract var c2: Int set(v: Int) { field = v } + abstract var c3: Int = 0; set(v: Int) { field = v } val e: Int get() = a val e1: Int = 0; get() = a - abstract val e2: Int get() = a - abstract val e3: Int = 0; get() = a + abstract val e2: Int get() = a + abstract val e3: Int = 0; get() = a //methods fun f() fun g() {} - abstract fun h() + abstract fun h() abstract fun j() {} } diff --git a/idea/testData/quickfix/abstract/redundantAbstract.kt b/idea/testData/quickfix/abstract/redundantAbstract.kt deleted file mode 100644 index 64c1228fc3c..00000000000 --- a/idea/testData/quickfix/abstract/redundantAbstract.kt +++ /dev/null @@ -1,4 +0,0 @@ -// "Remove redundant 'abstract' modifier" "true" -interface A { - abstract fun foo() -} \ No newline at end of file diff --git a/idea/testData/quickfix/abstract/redundantAbstract.kt.after b/idea/testData/quickfix/abstract/redundantAbstract.kt.after deleted file mode 100644 index dc9e9ed81e0..00000000000 --- a/idea/testData/quickfix/abstract/redundantAbstract.kt.after +++ /dev/null @@ -1,4 +0,0 @@ -// "Remove redundant 'abstract' modifier" "true" -interface A { - fun foo() -} \ No newline at end of file diff --git a/idea/testData/quickfix/redundantModalityModifier/redundantAbstract.kt b/idea/testData/quickfix/redundantModalityModifier/redundantAbstract.kt new file mode 100644 index 00000000000..66f35f96aee --- /dev/null +++ b/idea/testData/quickfix/redundantModalityModifier/redundantAbstract.kt @@ -0,0 +1,4 @@ +// "Remove redundant modality modifier" "true" +interface A { + abstract fun foo() +} \ No newline at end of file diff --git a/idea/testData/quickfix/redundantModalityModifier/redundantAbstract.kt.after b/idea/testData/quickfix/redundantModalityModifier/redundantAbstract.kt.after new file mode 100644 index 00000000000..26a140ca1cf --- /dev/null +++ b/idea/testData/quickfix/redundantModalityModifier/redundantAbstract.kt.after @@ -0,0 +1,4 @@ +// "Remove redundant modality modifier" "true" +interface A { + fun foo() +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 102f3988ef9..92904c79fc6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -193,12 +193,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } - @TestMetadata("redundantAbstract.kt") - public void testRedundantAbstract() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/abstract/redundantAbstract.kt"); - doTest(fileName); - } - @TestMetadata("replaceOpen.kt") public void testReplaceOpen() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/abstract/replaceOpen.kt"); @@ -6406,6 +6400,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/redundantModalityModifier"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); } + @TestMetadata("redundantAbstract.kt") + public void testRedundantAbstract() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/redundantModalityModifier/redundantAbstract.kt"); + doTest(fileName); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/redundantModalityModifier/simple.kt");